prasadshet
prasadshet

Reputation: 96

how to derivate with respect to someother variable other than time?

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

Answers (3)

modelicaFan
modelicaFan

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

Dietmar Winkler
Dietmar Winkler

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

Kjetil Sonerud
Kjetil Sonerud

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

Related Questions