From 78ede244a226da452e24e2b8f4391c06c4ea053e Mon Sep 17 00:00:00 2001 From: tobolar Date: Wed, 11 Mar 2015 11:29:31 +0100 Subject: [PATCH] Imrpved documentation of some elements and deleted redundant variables from SpringDamper --- PlanarMechanics/Interfaces/Frame.mo | 6 +- PlanarMechanics/Interfaces/Frame_a.mo | 2 +- PlanarMechanics/Interfaces/Frame_b.mo | 2 +- PlanarMechanics/Parts/Fixed.mo | 3 +- PlanarMechanics/Parts/Spring.mo | 32 +++++----- PlanarMechanics/Parts/SpringDamper.mo | 89 +++++++++++++-------------- 6 files changed, 65 insertions(+), 69 deletions(-) diff --git a/PlanarMechanics/Interfaces/Frame.mo b/PlanarMechanics/Interfaces/Frame.mo index 53936b3d..6eff9214 100644 --- a/PlanarMechanics/Interfaces/Frame.mo +++ b/PlanarMechanics/Interfaces/Frame.mo @@ -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="

Developed 2010-2014 at the DLR Institute of System Dynamics and Control

", info=" -

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.

+

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.

")); end Frame; diff --git a/PlanarMechanics/Interfaces/Frame_a.mo b/PlanarMechanics/Interfaces/Frame_a.mo index 777fdd0b..353787ee 100644 --- a/PlanarMechanics/Interfaces/Frame_a.mo +++ b/PlanarMechanics/Interfaces/Frame_a.mo @@ -40,6 +40,6 @@ connector Frame_a lineColor={0,0,0}, textString="%name")}), Documentation(revisions="

Developed 2010-2014 at the DLR Institute of System Dynamics and Control

", info=" -

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 Frame_b.

+

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 Frame_b.

")); end Frame_a; diff --git a/PlanarMechanics/Interfaces/Frame_b.mo b/PlanarMechanics/Interfaces/Frame_b.mo index 919e74a4..e9cebc5a 100644 --- a/PlanarMechanics/Interfaces/Frame_b.mo +++ b/PlanarMechanics/Interfaces/Frame_b.mo @@ -40,6 +40,6 @@ connector Frame_b lineColor={0,0,0}, textString="%name")}), Documentation(revisions="

Developed 2010-2014 at the DLR Institute of System Dynamics and Control

", info=" -

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 Frame_a.

+

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 Frame_a.

")); end Frame_b; diff --git a/PlanarMechanics/Parts/Fixed.mo b/PlanarMechanics/Parts/Fixed.mo index 670e6ba2..bf86516c 100644 --- a/PlanarMechanics/Parts/Fixed.mo +++ b/PlanarMechanics/Parts/Fixed.mo @@ -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 diff --git a/PlanarMechanics/Parts/Spring.mo b/PlanarMechanics/Parts/Spring.mo index 10de28e9..1d51ad2a 100644 --- a/PlanarMechanics/Parts/Spring.mo +++ b/PlanarMechanics/Parts/Spring.mo @@ -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( @@ -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; diff --git a/PlanarMechanics/Parts/SpringDamper.mo b/PlanarMechanics/Parts/SpringDamper.mo index 71f6bca0..4765efad 100644 --- a/PlanarMechanics/Parts/SpringDamper.mo +++ b/PlanarMechanics/Parts/SpringDamper.mo @@ -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( @@ -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", @@ -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( @@ -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( @@ -120,7 +116,6 @@ 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, @@ -128,7 +123,7 @@ protected 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; @@ -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; @@ -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;