Engee物理建模语言方程
|
页面进行中。 |
声明方程
方程 物理组件使用构造声明 @方程. 波浪号用作相等符号。 ~.
@equations begin
x ~ y * z
y ~ 2 * t
end
这里 t --这是一个时间变量,总是以秒为单位测量。
在显式方程中使用的所有数字都被认为是无量纲的(在SI系统中)。
有关复杂情况(包括条件方程和分支)的更多信息,请参阅文章 Enee物理建模语言的枚举、分支、循环和模块。
矢量方程
当整个数组同时相等时,方程也可以以矢量形式设置。 有关详细信息,请参阅文章 Enee物理建模语言的枚举、分支、循环和模块。
插值和外推
对于表格插值和外推,使用函数 桌上型查询 用多种方法:
-
tablelookup(X_vector::Vector,y_vector::Vector,x,插值,外推)-一维插值; -
tablelookup(X1_vector::Vector,x2_vector::Vector,y_matrix::Matrix,X1,x2,插值,外推)-2D插值; -
tablelookup(X1_vector::Vector,x2_vector::Vector,x3_vector::Vector,y_3d_array::Array,X1,x2,x3,插值,外推)-3d插值。
支持的模式:
-
插值法:-
"线性"-分段线性; -
"光滑"-akim的分段三次修正插值。
-
-
外推法:-
"线性"-线性(在两个极端点为"线性",与极值多项式相切为"光滑"); -
"最近"-在最近的极值。
-
除此以外的论点 插值法 和 外推法 它们可以是符号或非符号。 将第一组设置为非符号(带有数组参数)是可以接受的 x_探测器, …, y_3d_阵列),以及字符中的第二个(x, x1, x2, x3).
支票
条件检查由函数执行 assert(条件,消息,操作) 结构内部 @方程:
@parameters begin
a = 1
assert_action::AssertAction = AssertAction.error
end
@equations begin
assert(a>0, "This is error.", assert_action)
end
使用格式:
-
断言(x>0)-例行检查,在违反的情况下,计算将停止; -
断言(x>0,"错误")-带有指定的错误消息; -
assert(x>0,"",AssertAction.无)-没有文字,只有动作设置。
开始! 它可以是一个符号参数,并取值:
-
断言。无-什么都不做; -
断言。错误-停止计算(默认情况下)。
特征:
-
如果检查仅包含数字和参数,则在模拟开始时执行一次。;
-
如果至少有一个变量,则在模拟的每个步骤检查它(在块中启用*运行时断言*选项 求解器配置).
对于复合条件,操作符 || 和 && 它们只在没有端口和变量的情况下工作。 如果有的话,你应该使用 | 和 &.
联系
-
均衡连接端口的潜在变量;
-
连接端口的流变量之和等于零。
@components begin
resistor = EngeePhysicalFoundation.Electrical.Elements.Resistor()
capacitor = EngeePhysicalFoundation.Electrical.Elements.Capacitor()
reference = EngeePhysicalFoundation.Electrical.Elements.Reference()
end
@equations begin
connect(resistor.p, capacitor.n)
connect(capacitor.p, resistor.n, reference.pin)
end
如果使用功能 连接 有争论 *,那么端口中的潜在变量将为0。
@engeemodel ground begin
@nodes begin
pin = EngeePhysicalFoundation.Electrical.Pin
end
@equations begin
connect(pin, *)
end
end
除了方程之外,连接端口的参数也是相等的。
在分支中使用*
在构造中定义的分支 @分行,将物理组件的变量与端口的流变量相关联,并定义模型内流的拓扑。 符号 * 它用于指示stream变量没有连接到其他端口。 例子::
@engeemodel FloatingReference begin
@nodes begin
p = EngeePhysicalFoundation.Electrical.Pin
n = EngeePhysicalFoundation.Electrical.Pin
out = EngeePhysicalFoundation.Electrical.Pin
end
@variables [access = Private] begin
i_input = 0, [unit = "A", description = "Input current"]
end
@variables begin
i_output = 0, [unit = "A", description = "Current into output node"]
end
@branches begin
i_input:(p.i,n.i)#i_input电流在端口p和n之间流动
i_output:(出。i,*)#i_output电流流入out端口,而无需连接另一侧的任何地方
end
end
这里:
-
i_input:(p.i,n.i)--表示变量i_输入对应于来自端口的流p到港口n; -
i_output:(出。i,*)--表示当前i_输出流入港口出,但它没有配对的短路端口。