H = energyfunction(x, v, F, E);
Returns the partial derivative of an energy function and the derivative of the energy variable. Used for port hamiltonian functions.
F = d(E)/dx
v = ddt(x) or x = int(v);
x and v have a causal relation: one of them should be an input and one of them should be an output.
In this example the potential energy of a spring is given by the variable E. E is defined as a function of the variable x.
parameters
real k = 1000 {N/m};
variables
real H {J}; // spring energy (potential)
real x {m};
real v {m/s};
real F {N};
real E {J};
equations
v = sin (time);
E = 0.5*k*x^2;
H = energyfunction ( x , v, F , E );
20-sim will (symbolically) solve this to:
F = d(E)/dx = 0.5 * k * 2 * x
and
x = int(v)
• | The partial derivative of the energy function should exist and will be symbolically solved by 20-sim. |
• | If the variable x is and input for the function, the time derivative to yield the variable v will be symbolically solved if possible. |
• | The function only accepts scalar inputs. |