Reputation: 139
I have a model in which one of the parameters should be found by solving a nonlinear equation. Is it possible to implement one such case in Modelica? For example:
parameter Real Rs
should be found by solving the equation:
(VmaxP*(Isc+I0_diode-2*ImaxP)-ImaxP*I0_diode*Rs)/(VmaxP-Rs*ImaxP)+I0_diode*exp((VmaxP+Rs*ImaxP)/(a*Ns*Vth_diode))*((Rs*(ImaxP-Isc)+VmaxP-a*Ns*Vth_diode)/(a*Ns*Vth_diode))=0;
in the above nonlinear equation, only Rs
is unknown.
Upvotes: 3
Views: 78
Reputation: 6645
Parameters can be computed in the initial equation section when they are declared with fixed=false
. Just put your nonlinear equation into this section and Rs
will be computed if all other variables are known.
model FixedFalse
parameter Real Rs(fixed=false);
// dummy values to let the model simulate
Real VmaxP=1; Real Isc=1; Real I0_diode=1;
Real ImaxP=1; Real a = 1; Real Ns = 1; Real Vth_diode = 1;
initial equation
(VmaxP*(Isc+I0_diode-2*ImaxP)-ImaxP*I0_diode*Rs)/(VmaxP-Rs*ImaxP)+I0_diode*exp((VmaxP+Rs*ImaxP)/(a*Ns*Vth_diode))*((Rs*(ImaxP-Isc)+VmaxP-a*Ns*Vth_diode)/(a*Ns*Vth_diode))=0;
end FixedFalse;
To prevent that this parameter is shown in the parameter dialog, you can protect it and add a non-final parameter, e.g. for plotting:
...
final parameter Real Rs = _Rs;
protected
parameter Real _Rs(fixed=false);
initial equation
// Now use _Rs here
...
Upvotes: 2