You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have implemeted a simple Pendulom Example in the FMU generator and It worked. Now I would like to implementthe same logic but this time withuot depending on a internal time factor h , but depending ona external time factor which is giving by the simulator (in this case Matlab) or more direct by the <defaultExperiment. data placed on the modelDescription.xml.
Implementation of the Rungakutta Solver in to the UpdateIfModified Function
`
double g = m_realVar[FMI_PARA_g];
double l = m_realVar[FMI_PARA_l];
double b = m_realVar[FMI_PARA_b];
double m = m_realVar[FMI_PARA_m];
double Ang = m_realVar[FMI_LOCAL_Ang];
double vel = m_realVar[FMI_LOCAL_vel];
//Runga Kutta Method
double h=0.01;
double dx1,dx2,dx3,dx4,dx;
double dv1,dv2,dv3,dv4,dv;
dx1=h*vel;
dv1=h*dydx(Ang,vel,g,l,b,m);
dx2=h*(vel+0.5*dv1);
dv2=h*dydx(Ang+0.5*dx1,vel+0.5*dv1,g,l,b,m);
dx3=h*(vel+0.5*dv2);
dv3=h*dydx(Ang+0.5*dx2,vel+0.5*dv1,g,l,b,m);
dx4=h*(vel+dv3);
dv4=h*dydx(Ang+dx3,vel+dv1,g,l,b,m);
dx=(dx1+2*dx2+2*dx3+dx4)/6;
dv=(dv1+2*dv2+2*dv3+dv4)/6;
Ang=Ang+dx;
vel=vel+dv;
// output variables
m_realVar[FMI_OUTPUT_Ace] = Ang;
//Update Angle and Velocity values
m_realVar[FMI_LOCAL_Ang]=Ang;
m_realVar[FMI_LOCAL_vel]=vel;
Yes I would like to test it in different platforms and also setting different timesteps on them.
So it is not good idea to define internally the Steptime. In other words I would like to get the h value from outside or from the <defaultExperiment data
I have implemeted a simple Pendulom Example in the FMU generator and It worked. Now I would like to implementthe same logic but this time withuot depending on a internal time factor
h
, but depending ona external time factor which is giving by the simulator (in this case Matlab) or more direct by the<defaultExperiment.
data placed on the modelDescription.xml.Implementation of the Rungakutta Solver in to the UpdateIfModified Function
`
`
With the ODE function
float dydx(double x, double v,double g,double l,double b, double m) { return((-(g/l)*sin(x))-(b/m)*v); }
The text was updated successfully, but these errors were encountered: