Skip to content

Commit

Permalink
Imrpved documentation of some elements and deleted redundant variable…
Browse files Browse the repository at this point in the history
…s from SpringDamper
  • Loading branch information
tobolar committed Mar 11, 2015
1 parent 526b721 commit 78ede24
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 69 deletions.
6 changes: 3 additions & 3 deletions PlanarMechanics/Interfaces/Frame.mo
Expand Up @@ -3,10 +3,10 @@ connector Frame "General connector for planar mechanical components"
SI.Position x "x-position";
SI.Position y "y-position";
SI.Angle phi "Angle (counter-clockwise)";
flow SI.Force fx "Force in x-direction";
flow SI.Force fy "Force in y-direction";
flow SI.Force fx "Force in x-direction, resolved in planarWorld frame";
flow SI.Force fy "Force in y-direction, resolved in planarWorld frame";
flow SI.Torque t "Torque (clockwise)";
annotation (Documentation(revisions="<html><p><img src=\"modelica://PlanarMechanics/Resources/Images/dlr_logo.png\"/> <b>Developed 2010-2014 at the DLR Institute of System Dynamics and Control</b></p></html>", info="<html>
<p>Frame is a connector, which lies at the origin of the coordinate system attached to it. Cut-force and cut_torque act at the origin of the coordinate system. Normally, this connector is fixed to a mechanical component. But this model is never used directly in a system. It is only for usage of inheritance.</p>
<p>Frame is a connector, which lies at the origin of the coordinate system attached to it. Cut-force and cut_torque act at the origin of the coordinate system and are resolved in planarWorld frame. Normally, this connector is fixed to a mechanical component. But this model is never used directly in a system. It is only for usage of inheritance.</p>
</html>"));
end Frame;
2 changes: 1 addition & 1 deletion PlanarMechanics/Interfaces/Frame_a.mo
Expand Up @@ -40,6 +40,6 @@ connector Frame_a
lineColor={0,0,0},
textString="%name")}),
Documentation(revisions="<html><p><img src=\"modelica://PlanarMechanics/Resources/Images/dlr_logo.png\"/> <b>Developed 2010-2014 at the DLR Institute of System Dynamics and Control</b></p></html>", info="<html>
<p>Frame_a is a connector, which lies at the origin of the coordinate system attached to it. Cut-force and cut_torque act at the origin of the coordinate system. Normally, this connector is fixed to a mechanical component. The same as <a href=\"modelica://PlanarMechanics.Interfaces.Frame_b\">Frame_b</a>.</p>
<p>Frame_a is a connector, which lies at the origin of the coordinate system attached to it. Cut-force and cut_torque act at the origin of the coordinate system and are resolved in planarWorld frame. Normally, this connector is fixed to a mechanical component. The same as <a href=\"modelica://PlanarMechanics.Interfaces.Frame_b\">Frame_b</a>.</p>
</html>"));
end Frame_a;
2 changes: 1 addition & 1 deletion PlanarMechanics/Interfaces/Frame_b.mo
Expand Up @@ -40,6 +40,6 @@ connector Frame_b
lineColor={0,0,0},
textString="%name")}),
Documentation(revisions="<html><p><img src=\"modelica://PlanarMechanics/Resources/Images/dlr_logo.png\"/> <b>Developed 2010-2014 at the DLR Institute of System Dynamics and Control</b></p></html>", info="<html>
<p>Frame_b is a connector, which lies at the origin of the coordinate system attached to it. Cut-force and cut_torque act at the origin of the coordinate system. Normally, this connector is fixed to a mechanical component. The same as <a href=\"modelica://PlanarMechanics.Interfaces.Frame_a\">Frame_a</a>.</p>
<p>Frame_b is a connector, which lies at the origin of the coordinate system attached to it. Cut-force and cut_torque act at the origin of the coordinate system and are resolved in planarWorld frame. Normally, this connector is fixed to a mechanical component. The same as <a href=\"modelica://PlanarMechanics.Interfaces.Frame_a\">Frame_a</a>.</p>
</html>"));
end Frame_b;
3 changes: 2 additions & 1 deletion PlanarMechanics/Parts/Fixed.mo
Expand Up @@ -2,7 +2,8 @@ within PlanarMechanics.Parts;
model Fixed
"Frame fixed in the planar world frame at a given position and orientation"

parameter SI.Position r[2] = {0,0} "Fixed x,y-position";
parameter SI.Position r[2] = {0,0}
"Fixed absolute x,y-position, resolved in planarWorld frame";
parameter SI.Angle phi = 0 "Fixed angle";

Interfaces.Frame_b frame
Expand Down
32 changes: 16 additions & 16 deletions PlanarMechanics/Parts/Spring.mo
Expand Up @@ -4,25 +4,25 @@ model Spring "Linear 2D translational spring"

parameter StateSelect stateSelect=StateSelect.default
"Priority to use phi and w as states" annotation(HideResult=true,Dialog(tab="Advanced"));
parameter Modelica.SIunits.TranslationalSpringConstant c_x(final min=0, start=1)
parameter SI.TranslationalSpringConstant c_x(final min=0, start=1)
"Spring constant in x dir";
parameter Modelica.SIunits.TranslationalSpringConstant c_y(final min=0, start=1)
parameter SI.TranslationalSpringConstant c_y(final min=0, start=1)
"Spring constant in y dir";
parameter Modelica.SIunits.RotationalSpringConstant c_phi(final min=0, start=1.0e5)
parameter SI.RotationalSpringConstant c_phi(final min=0, start=1.0e5)
"Spring constant";
parameter Modelica.SIunits.Position s_relx0=0 "Unstretched spring length";
parameter Modelica.SIunits.Position s_rely0=0 "Unstretched spring length";
parameter Modelica.SIunits.Angle phi_rel0=0 "Unstretched spring angle";
parameter SI.Position s_relx0=0 "Unstretched spring length";
parameter SI.Position s_rely0=0 "Unstretched spring length";
parameter SI.Angle phi_rel0=0 "Unstretched spring angle";

Modelica.SIunits.Position s_relx(final stateSelect=stateSelect, start = 0)
"Spring length" annotation(Dialog(group="Initialization", showStartAttribute=true));
Modelica.SIunits.Position s_rely(final stateSelect=stateSelect, start = 0)
"Spring length" annotation(Dialog(group="Initialization", showStartAttribute=true));
SI.Position s_relx(final stateSelect=stateSelect, start = 0) "Spring length"
annotation(Dialog(group="Initialization", showStartAttribute=true));
SI.Position s_rely(final stateSelect=stateSelect, start = 0) "Spring length"
annotation(Dialog(group="Initialization", showStartAttribute=true));

Modelica.SIunits.Angle phi_rel(final stateSelect=stateSelect, start = 0)
"Spring angle" annotation(Dialog(group="Initialization", showStartAttribute=true));
Modelica.SIunits.Force f_x "Force in x direction";
Modelica.SIunits.Force f_y "Force in y direction";
SI.Angle phi_rel(final stateSelect=stateSelect, start = 0) "Spring angle"
annotation(Dialog(group="Initialization", showStartAttribute=true));
SI.Force f_x "Force in x direction";
SI.Force f_y "Force in y direction";

parameter SI.Position s_small = 1.E-10
"Prevent zero-division if distance between frame_a and frame_b is zero" annotation (Dialog(
Expand Down Expand Up @@ -51,9 +51,9 @@ model Spring "Linear 2D translational spring"
SI.Length length
"Distance between the origin of frame_a and the origin of frame_b";
SI.Position r_rel_0[3]
"Position vector from frame_a to frame_b resolved in world frame";
"Position vector (3D) from frame_a to frame_b resolved in multibody world frame";
Real e_rel_0[3](each final unit="1")
"Unit vector in direction from frame_a to frame_b, resolved in world frame";
"Unit vector (3D) in direction from frame_a to frame_b, resolved in multibody world frame";

//Visualization
import MB = Modelica.Mechanics.MultiBody;
Expand Down
89 changes: 42 additions & 47 deletions PlanarMechanics/Parts/SpringDamper.mo
Expand Up @@ -7,35 +7,31 @@ model SpringDamper "Linear 2D translational spring damper model"

parameter StateSelect stateSelect=StateSelect.default
"Priority to use phi, w and a as states" annotation(HideResult=true,Dialog(tab="Advanced"));
parameter Modelica.SIunits.TranslationalSpringConstant c_x(final min=0, start=1)
parameter SI.TranslationalSpringConstant c_x(final min=0, start=1)
"Spring constant in x dir";
parameter Modelica.SIunits.TranslationalSpringConstant c_y(final min=0, start=1)
parameter SI.TranslationalSpringConstant c_y(final min=0, start=1)
"Spring constant in y dir";
parameter Modelica.SIunits.RotationalSpringConstant c_phi(final min=0, start=1.0e5)
parameter SI.RotationalSpringConstant c_phi(final min=0, start=1.0e5)
"Spring constant";
parameter Modelica.SIunits.TranslationalDampingConstant d_x(final min=0, start=1)
parameter SI.TranslationalDampingConstant d_x(final min=0, start=1)
"Damping constant in x dir";
parameter Modelica.SIunits.TranslationalDampingConstant d_y(final min=0, start=1)
parameter SI.TranslationalDampingConstant d_y(final min=0, start=1)
"Damping constant in y dir";
parameter Modelica.SIunits.RotationalDampingConstant d_phi(final min=0, start=1)
parameter SI.RotationalDampingConstant d_phi(final min=0, start=1)
"Damping constant in phi dir";
parameter Modelica.SIunits.Position s_relx0=0 "Unstretched spring length";
parameter Modelica.SIunits.Position s_rely0=0 "Unstretched spring length";
parameter Modelica.SIunits.Angle phi_rel0=0 "Unstretched spring angle";
parameter SI.Position s_relx0=0 "Unstretched spring length";
parameter SI.Position s_rely0=0 "Unstretched spring length";
parameter SI.Angle phi_rel0=0 "Unstretched spring angle";

Real[2] d0;
Modelica.SIunits.Velocity v_relx "Spring velocity";
Modelica.SIunits.Velocity v_rely "Spring velocity";
Modelica.SIunits.AngularVelocity w_rel(start=0) "Spring anglular velocity" annotation(Dialog(group="Initialization", showStartAttribute=true));
Modelica.SIunits.Position s_relx(final stateSelect=stateSelect)
"Spring length";
Modelica.SIunits.Position s_rely(final stateSelect=stateSelect)
"Spring length";
Modelica.SIunits.Angle phi_rel(start=0, final stateSelect=stateSelect)
"Spring angle" annotation(Dialog(group="Initialization", showStartAttribute=true));
Modelica.SIunits.Force f_x "Force in x direction";
Modelica.SIunits.Force f_y "Force in y direction";
Modelica.SIunits.Torque tau "Torque between frames (= frame_b.f)";
SI.Velocity v_relx "Spring velocity";
SI.Velocity v_rely "Spring velocity";
SI.AngularVelocity w_rel(start=0) "Spring anglular velocity" annotation(Dialog(group="Initialization", showStartAttribute=true));
SI.Position s_relx(final stateSelect=stateSelect) "Spring length";
SI.Position s_rely(final stateSelect=stateSelect) "Spring length";
SI.Angle phi_rel(start=0, final stateSelect=stateSelect) "Spring angle" annotation(Dialog(group="Initialization", showStartAttribute=true));
SI.Force f_x "Force in x direction";
SI.Force f_y "Force in y direction";
SI.Torque tau "Torque between frames (= frame_b.f)";

parameter SI.Position s_small = 1.E-10
"Prevent zero-division if distance between frame_a and frame_b is zero" annotation (Dialog(
Expand All @@ -45,46 +41,46 @@ model SpringDamper "Linear 2D translational spring damper model"
"Cause an assert when the distance between frame_a and frame_b < s_small" annotation (Dialog(
tab="Advanced"));

//Visualization
parameter Boolean animate = true "Enable animation"
annotation(Dialog(group="Animation"));
parameter SI.Length zPosition = planarWorld.defaultZPosition
"Position z of cylinder representing the fixed translation" annotation (Dialog(
tab="Animation", group="if animation = true", enable=animate));
parameter Integer numberOfWindings = 5 "Number of spring windings"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
annotation (Dialog(tab="Animation", group="Spring coil (if animation = true)", enable=animate));
input SI.Length width = planarWorld.defaultForceWidth "Width of spring"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
annotation (Dialog(tab="Animation", group="Spring coil (if animation = true)", enable=animate));
input SI.Length coilWidth = width/10 "Width of spring coil"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
input Modelica.Mechanics.MultiBody.Types.SpecularCoefficient
annotation (Dialog(tab="Animation", group="Spring coil (if animation = true)", enable=animate));
input MB.Types.SpecularCoefficient
specularCoefficient = planarWorld.defaultSpecularCoefficient
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
input Types.Color color = Types.Defaults.SpringColor "Color of spring"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
annotation (Dialog(tab="Animation", group="Spring coil (if animation = true)", enable=animate));

parameter SI.Length length_a = planarWorld.defaultForceLength
"Length of cylinder at frame_a side"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
annotation (Dialog(tab="Animation", group="Spring cylinders (if animation = true)", enable=animate));
input SI.Diameter diameter_a = planarWorld.defaultForceWidth
"Diameter of cylinder at frame_a side"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
annotation (Dialog(tab="Animation", group="Spring cylinders (if animation = true)", enable=animate));
input SI.Diameter diameter_b = 0.6*diameter_a
"Diameter of cylinder at frame_b side"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate));
annotation (Dialog(tab="Animation", group="Spring cylinders (if animation = true)", enable=animate));
input Types.Color color_a = {100,100,100} "Color at frame_a"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate, colorSelector));
annotation (Dialog(tab="Animation", group="Spring cylinders (if animation = true)", enable=animate, colorSelector));
input Types.Color color_b = {155,155,155} "Color at frame_b"
annotation (Dialog(tab="Animation", group="if animation = true", enable=animate, colorSelector));
annotation (Dialog(tab="Animation", group="Spring cylinders (if animation = true)", enable=animate, colorSelector));

SI.Length length
"Distance between the origin of frame_a and the origin of frame_b";
SI.Position r_rel_0[3]
"Position vector from frame_a to frame_b resolved in world frame";
"Position vector (3D) from frame_a to frame_b resolved in multibody world frame";
Real e_rel_0[3](each final unit="1")
"Unit vector in direction from frame_a to frame_b, resolved in world frame";
"Unit vector (3D) in direction from frame_a to frame_b, resolved in multibody world frame";

//Visualization
import MB = Modelica.Mechanics.MultiBody;
parameter Boolean animate = true "Enable animation"
annotation(Dialog(group="Animation"));
protected
MB.Visualizers.Advanced.Shape contactA(
shapeType="cylinder",
Expand All @@ -94,7 +90,7 @@ protected
height=0.1,
lengthDirection={0,0,1},
widthDirection={1,0,0},
r_shape={0,0,-0.06},
r_shape={0,0,-0.05},
r=MB.Frames.resolve1(planarWorld.R,{frame_a.x,frame_a.y,zPosition})+planarWorld.r_0,
R=planarWorld.R) if planarWorld.enableAnimation and animate;
MB.Visualizers.Advanced.Shape contactB(
Expand All @@ -105,7 +101,7 @@ protected
height=0.1,
lengthDirection={0,0,1},
widthDirection={1,0,0},
r_shape={0,0,-0.06},
r_shape={0,0,-0.05},
r=MB.Frames.resolve1(planarWorld.R,{frame_b.x,frame_b.y,zPosition})+planarWorld.r_0,
R=planarWorld.R) if planarWorld.enableAnimation and animate;
MB.Visualizers.Advanced.Shape lineShape(
Expand All @@ -120,15 +116,14 @@ protected
extra=numberOfWindings,
r=MB.Frames.resolve1(planarWorld.R,{frame_a.x,frame_a.y,zPosition})+planarWorld.r_0,
R=planarWorld.R) if planarWorld.enableAnimation and animate;
SI.Position r0_b[3] = {d0[1], d0[2], 0} * noEvent(min(length_a, length));
MB.Visualizers.Advanced.Shape shape_a(
shapeType="cylinder",
color=color_a,
specularCoefficient=specularCoefficient,
length=noEvent(min(length_a, length)),
width=diameter_a,
height=diameter_a,
lengthDirection={d0[1], d0[2], 0},
lengthDirection={s_relx, s_rely, 0},
widthDirection={0,1,0},
r=MB.Frames.resolve1(planarWorld.R,{frame_a.x,frame_a.y,zPosition})+planarWorld.r_0,
R=planarWorld.R) if planarWorld.enableAnimation and animate;
Expand All @@ -141,7 +136,7 @@ protected
height=diameter_b,
lengthDirection={s_relx, s_rely, 0},
widthDirection={0,1,0},
r_shape=r0_b,
r_shape=Modelica.Math.Vectors.normalize(r_rel_0) * noEvent(min(length_a, length)),
r=MB.Frames.resolve1(planarWorld.R,{frame_a.x,frame_a.y,zPosition})+planarWorld.r_0,
R=planarWorld.R) if planarWorld.enableAnimation and animate;

Expand Down Expand Up @@ -188,18 +183,18 @@ equation
");
r_rel_0 = {s_relx, s_rely, 0};
length = Modelica.Math.Vectors.length(r_rel_0);
e_rel_0 = r_rel_0/Modelica.Mechanics.MultiBody.Frames.Internal.maxWithoutEvent(length, s_small);
d0= Modelica.Math.Vectors.normalize({s_relx,s_rely});
e_rel_0 = r_rel_0/MB.Frames.Internal.maxWithoutEvent(length, s_small);

s_relx = frame_b.x-frame_a.x;
s_rely = frame_b.y-frame_a.y;
v_relx = der(s_relx);
v_rely = der(s_rely);
w_rel = der(phi_rel);
phi_rel = frame_b.phi - frame_a.phi;

tau = c_phi*(phi_rel - phi_rel0) + d_phi*w_rel;
frame_a.t = -tau;
frame_b.t = tau;
s_relx = frame_b.x-frame_a.x;
s_rely = frame_b.y-frame_a.y;
f_x = c_x*(s_relx - s_relx0) + d_x*v_relx;
f_y = c_y*(s_rely - s_rely0) + d_y*v_rely;
frame_a.fx = -f_x;
Expand Down

0 comments on commit 78ede24

Please sign in to comment.