Hello,
I could use some help after all. The only thing I still need to work out (and I hope it’s possible at all) is to obtain the quaternion that I have calculated the previous time step. I’ve tried many things, but none worked so far:
1\ Using AnyVar, AnyOutputFun or just refer to the value at the previous time-step straight away (e.g Quaternion[iStep-1] ). Most of these ‘solutions’ end up in circular references or other errors.
2\ Storing the calculated value in a txt-file and read it. But it seems the file is only read once just before the simulations start.
3\ Define a separate study (Study 1) to perform the quaternion multiplication and call this study each time step from a second study (Study 2) and store the Quaternion value there. I succeeded somewhat at this last point, but only using a parameter study as Study 2 (with Analysis = Study1.Kinematics). But it’s slow and not working properly.
Now I’m trying use the calculated quaternions stored in an output function after all. Then in the next time step I refer to last calculated quaternion q[iStep-1], so I need an if statement to use the initial quaternion in the first time step (see below). However, for the if-function to work, ‘q1[0-1]’ needs to exist even though it will not be used, as in that case …t = min(…tArray)).
iffun(eqfun(…t,min(…tArray)),.InitialValues.q1_i,q1[iStep-1])
After solving this (see below), I get the all to familiar ‘circular dependence’ error during loading:
Code to prevent reference to q[-1]:
// Make sure ther is no reference to q[-1]
AnyInt iStep = iffun(eqfun(…t,min(…tArray)),…iStep,…iStep-1);
AnyFloat Test = .NextQ.Q1out()[iStep][0];
// Current quaternion seg 1 (initial value at 1st timestep)
AnyFloat q1_1 = iffun(eqfun(…t,min(…tArray)),.InitialValues.q1_i[0],Test);
Error:
ERROR(SCR.PRS7) : D:/AnyBody/P…m/OmegaDriven/TryIteration.any : ‘Test’ : Circular dependency in expression
Hope my attempts are clear ;). Is there any way to solve my problem within AnyBody (because I’m running out of ideas and really starting to thing it is not possible at all)?
Kind regards,