Modelica示例——一阶方程

 
 
 
 
//带初值的一阶微分方程求解
within ModelicaByExample.BasicEquations.SimpleExample;
model FirstOrderInitial "First order equation with initial value"
  Real x "State variable";
initial equation  //变量x的初始化方程
  x = 2 "Used before simulation to compute initial values";
equation
  der(x) = 1-x "Drives value of x toward 1.0";
  //变量微分方程
annotation(experiment(StartTime=0,StopTime=8));
//定义仿真开始时间和仿真终止时间,单位为秒(s)
 
 
end FirstOrderInitial;

 
 
//稳态起始的一阶微分方程求解
 
 
within ModelicaByExample.BasicEquations.SimpleExample;
model FirstOrderInitial "First order equation with initial value"
  Real x "State variable";
initial equation  //变量x的初始化方程  
 
 
der(x) = 0 "Initialize the system in steady state";
//变量的初始切线为水平线
equation
  der(x) = 1-x "Drives value of x toward 1.0";
  //变量微分方程
annotation(experiment(StartTime=0,StopTime=8));
//定义仿真开始时间和仿真终止时间,单位为秒(s)
 
 
end FirstOrderInitial;

//一维牛顿冷却方程
within ModelicaByExample.BasicEquations.CoolingExample;
model NewtonCooling "An example of Newton's law of cooling"
  parameter Real T_inf "Ambient temperature";//环境温度
  parameter Real T0 "Initial temperature";//初始温度
  parameter Real h "Convective cooling coefficient";//热对流系数
  parameter Real A "Surface area";//表面面积
  parameter Real m "Mass of thermal capacitance";//物体质量
  parameter Real c_p "Specific heat";//物体的比热容
  Real T "Temperature";//物体温度
initial equation
  T = T0 "Specify initial value for T";
  //物体温度
equation
  m*c_p*der(T) = -h*A*(T - T_inf) "Newton's law of cooling";
end NewtonCooling;


//带类型定义的一维冷却牛顿方程
within ModelicaByExample.BasicEquations.CoolingExample;
model NewtonCoolingWithTypes "Cooling example with physical types"
  // Types
  type Temperature=Real(unit="K", min=0);//定义新的类型;
  type ConvectionCoefficient=Real(unit="W/(m2.K)", min=0);
  type Area=Real(unit="m2", min=0);
  type Mass=Real(unit="kg", min=0);
  type SpecificHeat=Real(unit="J/(K.kg)", min=0);
 
 
  // Parameters
  parameter Temperature T_inf=298.15 "Ambient temperature";
  parameter Temperature T0=363.15 "Initial temperature";
  parameter ConvectionCoefficient h=0.7 "Convective cooling coefficient";
  parameter Area A=1.0 "Surface area";
  parameter Mass m=0.1 "Mass of thermal capacitance";
  parameter SpecificHeat c_p=1.2 "Specific heat";
 
 
  // Variables
  Temperature T "Temperature";
initial equation
  T = T0 "Specify initial value for T";
equation
  m*c_p*der(T) = h*A*(T_inf-T) "Newton's law of cooling";
end NewtonCoolingWithTypes;




猜你喜欢

转载自blog.csdn.net/bear_miao/article/details/80152397