我如何创建一个在 Modelica 中固定但可以围绕其重心自由旋转的物体?

问题描述 投票:0回答:1

我想在 Modelica 中模拟一个围绕其 CG 自由旋转的 3D 盒子。我该怎么做?

我尝试将它隔离到它在 3D 轴上的位置并对其施加扭矩,但我有非常基本的 Modelica 技能,我不知道如何做到这一点。

object modeling modelica openmodelica
1个回答
0
投票

下面的模型会有帮助吗?

各自的代码:

model RotatingBlock
  "for \"https://stackoverflow.com/questions/76051067/how-do-i-create-a-body-that-is-fixed-in-modelica-but-it-can-rotate-freely-about\""

  inner Modelica.Mechanics.MultiBody.World world annotation (Placement(transformation(extent={{-50,-10},{-30,10}})));
  Modelica.Mechanics.MultiBody.Joints.Spherical spherical annotation (Placement(transformation(extent={{-10,-10},{10,10}})));
  Modelica.Mechanics.MultiBody.Parts.BodyBox bodyBox(
    r={-0.1,0,0},
    r_shape={0.1,0,0},
    width=0.2,
    height=0.2) annotation (Placement(transformation(extent={{30,-10},{50,10}})));
  Modelica.Mechanics.MultiBody.Forces.WorldTorque torque annotation (Placement(transformation(extent={{-8,-70},{12,-50}})));
  Modelica.Blocks.Sources.Pulse tau_x(
    period=0.4,
    nperiod=1,
    startTime=0.1) annotation (Placement(transformation(extent={{-52,-46},{-40,-34}})));
  Modelica.Blocks.Sources.Constant tau_y(k=0) annotation (Placement(transformation(extent={{-52,-66},{-40,-54}})));
  Modelica.Blocks.Sources.Constant tau_z(k=0) annotation (Placement(transformation(extent={{-52,-86},{-40,-74}})));
  Modelica.Blocks.Routing.Multiplex3 multiplex3_1 annotation (Placement(transformation(extent={{-28,-66},{-16,-54}})));

equation 
  connect(spherical.frame_a, world.frame_b)
    annotation (Line(
      points={{-10,0},{-30,0}},
      color={95,95,95},
      thickness=0.5));
  connect(bodyBox.frame_a, spherical.frame_b)
    annotation (Line(
      points={{30,0},{10,0}},
      color={95,95,95},
      thickness=0.5));
  connect(torque.frame_b, bodyBox.frame_a)
    annotation (Line(
      points={{12,-60},{20,-60},{20,0},{30,0}},
      color={95,95,95},
      thickness=0.5));
  connect(multiplex3_1.y, torque.torque) annotation (Line(points={{-15.4,-60},{-10,-60}}, color={0,0,127}));
  connect(tau_x.y, multiplex3_1.u1[1])
    annotation (Line(points={{-39.4,-40},{-34,-40},{-34,-56},{-29.2,-56},{-29.2,-55.8}}, color={0,0,127}));
  connect(tau_y.y, multiplex3_1.u2[1]) annotation (Line(points={{-39.4,-60},{-29.2,-60}}, color={0,0,127}));
  connect(tau_z.y, multiplex3_1.u3[1])
    annotation (Line(points={{-39.4,-80},{-34,-80},{-34,-64},{-29.2,-64},{-29.2,-64.2}}, color={0,0,127}));
  annotation (uses(Modelica(version="4.0.0")));
end RotatingBlock;
© www.soinside.com 2019 - 2024. All rights reserved.