Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

der() operator

der() operator

Hi,
I just need an information about der() operator. I receive two signals as outputs of a C external function.
Then I've to put them in a system of equation.
If I write

Code:

Real vx(start=12);      

Real del(start=0);   
 
Real psi;   
Real phi;   

equation

(del,vx)=ExternalFunc1(val);
  phi=del*vx/10000000;
  vx=psi/cpitch;

it works properly.

But if I insert a der operator on the acquired variable.


Code:

Real vx;      

Real del;   
 
Real psi;   
Real phi;   

equation

(del,vx)=ExternalFunc1(val);
  phi=del*vx/10000000;
  der(vx)=psi/cpitch;

it gives me the following error:


resultFile = "Simulation failed.
Error: Model is structurally singular, error found sorting equations Algorithm no: 0 for inputs: () => outputs: (vx, del);
Algorithm no: 0 for inputs: () => outputs: (vx, del);
for variables del(3)

I tried also adding an initial equation but the result is the same. I think I'm making some mistake but I can't find it.
Can you help me please?

Regards,
Francesco

Re: der() operator

The problem here is that:
vx(t) + der(vx(t))*step = vx(t+1) in the next timestep. The function call can't provide vx(t+1) or der(vx(t)), so omc doesn't know how to handle that equation. I think that's because omc can only use integrating solvers (no way to change state variable that I know of).

I believe that you are thinking like I used to: der(x) = "(x-delay(x, step))/step". But that's the wrong slope when you use an integrating solver.

Re: der() operator

thank you very much for answering...
I used your (x-delay(x, step))/step instead of der(x) and it seems working..I hope it works too with a more complex model.
Thank you again,
Francesco

There are 0 guests and 0 other users also viewing this topic