Help with solving a system of coupled equations of motions in time domain?

4 visualizzazioni (ultimi 30 giorni)
Hi,
I've posted a similar post here, and I learned much through that post and comments. Now, I'm building on it and the system of equations has become a bit more complex again. I will explain it here again. Following were the set of equations I had, as I mentioned in the earlier post (linked).
But now, suppose I have another time-varying function added to each equation above. For instance, each DoF noted above includes another function f_1(t) (in fact, my system includes several of these, but I'm using one here for explanation). For example, as below.
So, I understand that these additional "functions" affects the system of equations at each time step. For example, f_1(t) here is the excitation loads due to air, as the object moves. i.e., one has to model it separately, and add a function/script to calculate that at the respective time step. Also, f_1(t) depends on the state variables which I am trying to solve.
For example, following what I had posted earlier (above linked), the equation system now changed to,
function sdot = learnF(A, B, s, data) % Equations to solve
sdot = [s(2) + f_1(inputs); % Added arbitrarily only to explain!!
data.m*s(4)*s(12) + Ctn*A(2,2,1)*s(4)*s(12) + A(2,4,1)*s(8)*s(12) + A(2,6,1)*s(12)^2;
s(4);
-data.m*s(2)*s(12) - A(1,1,1)*s(2)*s(12) - A(2,4,1)*s(8)
s(6);
-data.m*data.g;
s(8);
data.I(4,4)*s(10)*s(12);
s(10);
-data.I(4,4)*s(8)*s(12);
s(12);
(data.I(4,4)-data.I(6,6))*s(8)*s(10) + A(1,1,1)*s(2)*s(4) ...
- A(2,2,1)*s(2)*s(4) - A(2,4,1)*s(2)*s(8) - A(2,6,1)*s(2)*s(8) - A(6,4,1)*s(8)];
end
I added f_1(inputs) just arbitrarily (without deriving things) and I do know the placing could be wrong. The point is, now I have time-varying function within the function, which I have to solve using an ode solver. So my questions are;
  1. Did I understand the approach correctly here? If yes, how can I model this f_1(t) to use inputs from sdot? (I can feel that I am wrong here).
  2. I can, instead, use a for loop (time loop) and solve the equations step by step, but then I cannot use, for example, ode45 because I cannot solve ODE for one time step using that. Is there a work around for this?
  3. IF I can still use ode45 and solve this, can I get outputs of f_1(t) after the simulation?
My sincere apologies for the long and possibly confusing post, but I'm kind of helpless here. I'd appreicate any feedback!

Risposte (1)

Torsten
Torsten il 28 Mar 2023
Spostato: Torsten il 28 Mar 2023
How did you come up with the sdot vector for the equations so far ?
If you use a mass matrix, you simply have to add the additional force terms to the sdot vector.
A force term f1(t) in equation 1, e.g., has to be reflected as
sdot(2) = data.m*s(4)*s(12) + Ctn*A(2,2,1)*s(4)*s(12) + A(2,4,1)*s(8)*s(12) + A(2,6,1)*s(12)^2 + f1(t)
A force term f2(t) in equation 2 has to be reflected as
sdot(4) = -data.m*s(2)*s(12) - A(1,1,1)*s(2)*s(12) - A(2,4,1)*s(8) + f2(t)
and so on.
  4 Commenti
Jake
Jake il 29 Mar 2023
Thanks. I don't quite follow the first alternative, but the second one should be fine to implement.
Torsten
Torsten il 29 Mar 2023
Modificato: Torsten il 29 Mar 2023
For the first (quick-and-dirty) alternative:
if t < t0
f1 = ...;
else if t >= t0 && t <= t1
f1 = ...;
else if ...
...
else
...
end
But the second way is recommended.

Accedi per commentare.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by