Reputation: 96
I am just starting with modelica. I am aware that there is an inbuilt time derivative operator [der(expr)]. In case if i have to derivate with some other variable how can that be done ? for eg: if i have to derivate w.r.t a variable 'x' how can this be formed?
Upvotes: 3
Views: 1299
Reputation: 148
A simple solution to derive y over x, provided both variables are continuous, utilizes dy/dx = (dy/dt) / (dx/dt), i.e. in Modelica
dydx = der(y)/der(x)
.
We use it e.g. for derivatives of cartesian coordinates of a curve over its arc length.
Upvotes: 2
Reputation: 927
There is also the possibility of using the annotation derivative=<NameOfDerivativeFunction>
to tell the tool which function to use in order to take the derivative of your function:
Example from the Modelica Specification, chapter 12.7.1:
function foo0 annotation(derivative=foo1); end foo0;
function foo1 annotation(derivative(order=2)=foo2); end foo1;
function foo2 end foo2;
You can find more information in chapter 12.7.1. Maybe that helps.
Upvotes: 3
Reputation: 275
I guess you'll have to declare the derivative explicitly if you need something other than time derivatives, for example
y = x^2;
der_y = 2x;
The variable der_y should be declared earlier in the model, as should y and x. If you would like a double derivative, say, then you could do something like
dder_y = 2;
with the variable dder_y decleared earlier, as before.
I haven't often felt the need for other derivatives than time derivatives when making Modelica models. That being said, I'm quite new to Modelica myself, so there may very well come a time when I do.
Upvotes: 3