Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mustBeConnected annotation (introduced in Modelica 3.6) #4204

Merged
merged 8 commits into from
Jan 12, 2024

Conversation

HansOlsson
Copy link
Contributor

for all conditional support connectors in Rotational and Translational; based on decision in #4175

See "Modelica 3.6 - Changes, Benefits and Implementation" by Hans Olsson, from Modelica Conference 2023, https://www.conftool.com/modelica2023/index.php?page=browseSessions&form_session=34

In Dymola 2024x the library should still work after the change, but if you introduce an unconnected support connector in a model it will fail, e.g.:

model First "First example: simple drive train"
  extends Modelica.Icons.Example;
  parameter Modelica.Units.SI.Torque amplitude=10 "Amplitude of driving torque";
  parameter Modelica.Units.SI.Frequency f=5 "Frequency of driving torque";
  parameter Modelica.Units.SI.Inertia Jmotor(min=0)=0.1 "Motor inertia";
  parameter Modelica.Units.SI.Inertia Jload(min=0)=2 "Load inertia";
  parameter Real ratio=10 "Gear ratio";
  parameter Real damping=10 "Damping in bearing of gear";

  Modelica.Mechanics.Rotational.Components.Fixed fixed
    annotation (Placement(transformation(extent={{38,-48},{54,-32}})));
  Modelica.Mechanics.Rotational.Sources.Torque torque(useSupport=true)
    annotation (Placement(transformation(extent={{-68,-8},{-52,8}})));
  Modelica.Mechanics.Rotational.Components.Inertia inertia1(J=Jmotor)
    annotation (Placement(transformation(extent={{-38,-8},{-22,8}})));
  Modelica.Mechanics.Rotational.Components.IdealGear idealGear(ratio=ratio,
      useSupport=true)
    annotation (Placement(transformation(extent={{-8,-8},{8,8}})));
  Modelica.Mechanics.Rotational.Components.Inertia inertia2(
    J=2,
    phi(fixed=true, start=0),
    w(fixed=true, start=0))
    annotation (Placement(transformation(extent={{22,-8},{38,8}})));
  Modelica.Mechanics.Rotational.Components.Spring spring(c=1.e4, phi_rel(fixed=true))
    annotation (Placement(transformation(extent={{52,-8},{68,8}})));
  Modelica.Mechanics.Rotational.Components.Inertia inertia3(J=Jload, w(fixed=true,
        start=0))
    annotation (Placement(transformation(extent={{82,-8},{98,8}})));
  Modelica.Mechanics.Rotational.Components.Damper damper(d=damping) annotation 
    (Placement(transformation(
        origin={46,-22},
        extent={{-8,-8},{8,8}},
        rotation=270)));
  Modelica.Blocks.Sources.Sine sine(amplitude=amplitude, f=f)
    annotation (Placement(transformation(extent={{-98,-8},{-82,8}})));
equation 
  connect(inertia1.flange_b, idealGear.flange_a)
    annotation (Line(points={{-22,0},{-8,0}}));
  connect(idealGear.flange_b, inertia2.flange_a)
    annotation (Line(points={{8,0},{22,0}}));
  connect(inertia2.flange_b, spring.flange_a)
    annotation (Line(points={{38,0},{52,0}}));
  connect(spring.flange_b, inertia3.flange_a)
    annotation (Line(points={{68,0},{82,0}}));
  connect(damper.flange_a, inertia2.flange_b)
    annotation (Line(points={{46,-14},{46,0},{38,0}}));
  connect(damper.flange_b, fixed.flange)
    annotation (Line(points={{46,-30},{46,-40}}));
  connect(sine.y, torque.tau)
    annotation (Line(points={{-81.2,0},{-69.6,0}}, color={0,0,127}));
  connect(torque.support, fixed.flange)
    annotation (Line(points={{-60,-8},{-60,-40},{46,-40}}));
  connect(torque.flange, inertia1.flange_a) annotation (Line(
      points={{-52,0},{-38,0}}));
  annotation (
    experiment(StopTime=1.0, Interval=0.001),
    uses(Modelica(version="4.0.0")));
end First;

@HansOlsson HansOlsson added L: Mechanics.Rotational Issue addresses Modelica.Mechanics.Rotational L: Mechanics.Translational Issue addresses Modelica.Mechanics.Translational labels Oct 17, 2023
@beutlich beutlich added the requires Modelica 3.6 Issue that requires Modelica Language Specification 3.6 label Oct 18, 2023
Copy link
Contributor

@tobolar tobolar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@MartinOtter MartinOtter merged commit b8b2122 into modelica:master Jan 12, 2024
@beutlich beutlich removed the request for review from AHaumer January 12, 2024 18:27
@beutlich beutlich added this to the MSL4.1.0 milestone Jan 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: Mechanics.Rotational Issue addresses Modelica.Mechanics.Rotational L: Mechanics.Translational Issue addresses Modelica.Mechanics.Translational requires Modelica 3.6 Issue that requires Modelica Language Specification 3.6
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants