简体   繁体   English

Modelica 中的计算参数

[英]Computed parameter in Modelica

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?是否有可能在 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.在上述非线性方程中,只有Rs是未知的。

Parameters can be computed in the initial equation section when they are declared with fixed=false .当使用fixed=false声明参数时,可以在初始方程部分计算参数。 Just put your nonlinear equation into this section and Rs will be computed if all other variables are known.只需将您的非线性方程放入本节,如果所有其他变量都已知,则将计算Rs

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, eg for plotting:为防止此参数显示在参数对话框中,您可以保护它并添加一个非最终参数,例如用于绘图:

  ...

  final parameter Real Rs = _Rs;

protected 
  parameter Real _Rs(fixed=false);

initial equation 
  // Now use _Rs here
  ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM