假设我们要建立一个齿轮总成的模型,示意简图如下:
方法一:基于组件的建模
基于组件的建模是直接通过拖曳组件并将组件连接起来设定相应的参数值即可。
模型建立好后,切换至代码视图(自动生成代码)如下所示:
model Gear_assembly
extends Modelica.Icons.Example;
Modelica.Blocks.Sources.Trapezoid trapezoid1(period = 0.8) annotation(
Placement(visible = true, transformation(origin = {-118, 44}, extent = {
{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.Rotational.Sources.Torque torque1 annotation(
Placement(visible = true, transformation(origin = {-70, 44}, extent = {
{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Mechanics.Rotational.Components.Inertia inertia1(J =