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;




  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值