Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions Modelica/Mechanics/MultiBody/Forces/Internal/BasicForce.mo
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
within Modelica.Mechanics.MultiBody.Forces.Internal;
model BasicForce
"Force acting between two frames, defined by 3 input signals"
extends Modelica.Mechanics.MultiBody.Interfaces.PartialTwoFrames;
extends Interfaces.PartialForce;
import Modelica.Mechanics.MultiBody.Types.ResolveInFrameAB;

Interfaces.Frame_resolve frame_resolve
"The input signals are optionally resolved in this frame"
annotation (Placement(transformation(
Expand All @@ -22,36 +23,34 @@ model BasicForce

SI.Position r_0[3]
"Position vector from origin of frame_a to origin of frame_b resolved in world frame";
SI.Force f_b_0[3] "frame_b.f resolved in world frame";
SI.Force f_b_0[3] "Force frame_b.f resolved in world frame";

equation
assert(cardinality(frame_resolve) > 0, "Connector frame_resolve must be connected at least once and frame_resolve.r_0/.R must be set");
frame_resolve.f = zeros(3);
frame_resolve.t = zeros(3);

if resolveInFrame == ResolveInFrameAB.frame_a then
f_b_0 = -Frames.resolve1(frame_a.R, force);
frame_b.f = Frames.resolve2(frame_b.R, f_b_0);
elseif resolveInFrame == ResolveInFrameAB.frame_b then
f_b_0 = -Frames.resolve1(frame_b.R, force);
frame_b.f = -force;
elseif resolveInFrame == ResolveInFrameAB.world then
f_b_0 = -force;
frame_b.f = Frames.resolve2(frame_b.R, f_b_0);
elseif resolveInFrame == ResolveInFrameAB.frame_resolve then
f_b_0 = -Frames.resolve1(frame_resolve.R, force);
frame_b.f = Frames.resolve2(frame_b.R, f_b_0);
else
assert(false, "Wrong value for parameter resolveInFrame");
f_b_0 = zeros(3);
frame_b.f = zeros(3);
end if;
frame_b.t = zeros(3);
r_0 = frame_b.r_0 - frame_a.r_0;
frame_b.t = zeros(3);

if resolveInFrame == ResolveInFrameAB.frame_a then
f_b_0 = -Frames.resolve1(frame_a.R, force);
frame_b.f = Frames.resolve2(frame_b.R, f_b_0);
elseif resolveInFrame == ResolveInFrameAB.frame_b then
f_b_0 = -Frames.resolve1(frame_b.R, force);
frame_b.f = -force;
elseif resolveInFrame == ResolveInFrameAB.world then
f_b_0 = -force;
frame_b.f = Frames.resolve2(frame_b.R, f_b_0);
elseif resolveInFrame == ResolveInFrameAB.frame_resolve then
f_b_0 = -Frames.resolve1(frame_resolve.R, force);
frame_b.f = Frames.resolve2(frame_b.R, f_b_0);
else
assert(false, "Wrong value for parameter resolveInFrame");
f_b_0 = zeros(3);
frame_b.f = zeros(3);
end if;

// Force and torque balance
r_0 = frame_b.r_0 - frame_a.r_0;
zeros(3) = frame_a.f + Frames.resolve2(frame_a.R, f_b_0);
zeros(3) = frame_a.t + Frames.resolve2(frame_a.R, cross(r_0, f_b_0));
annotation (
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
100,100}}), graphics={
Expand Down
43 changes: 20 additions & 23 deletions Modelica/Mechanics/MultiBody/Forces/Internal/BasicTorque.mo
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
within Modelica.Mechanics.MultiBody.Forces.Internal;
model BasicTorque
"Torque acting between two frames, defined by 3 input signals"
extends Interfaces.PartialForce;
import Modelica.Mechanics.MultiBody.Types.ResolveInFrameAB;
extends Modelica.Mechanics.MultiBody.Interfaces.PartialTwoFrames;

Interfaces.Frame_resolve frame_resolve
"The input signals are optionally resolved in this frame"
annotation (Placement(transformation(
origin={40,100},
extent={{-16,-16},{16,16}},
rotation=90)));

Modelica.Blocks.Interfaces.RealInput torque[3](each final quantity="Torque", each final unit="N.m")
"x-, y-, z-coordinates of torque resolved in frame defined by resolveInFrame"
annotation (Placement(transformation(
Expand All @@ -23,37 +23,34 @@ model BasicTorque

SI.Position r_0[3]
"Position vector from origin of frame_a to origin of frame_b resolved in world frame";
SI.Torque t_b_0[3] "frame_b.t resolved in world frame";
SI.Torque t_b_0[3] "Torque frame_b.t resolved in world frame";

equation
assert(cardinality(frame_resolve) > 0, "Connector frame_resolve must be connected at least once and frame_resolve.r_0/.R must be set");
frame_resolve.f = zeros(3);
frame_resolve.t = zeros(3);

r_0 = frame_b.r_0 - frame_a.r_0;
frame_a.f = zeros(3);
frame_b.f = zeros(3);

if resolveInFrame == ResolveInFrameAB.frame_a then
t_b_0 = -Frames.resolve1(frame_a.R, torque);
frame_b.t = Frames.resolve2(frame_b.R, t_b_0);
elseif resolveInFrame == ResolveInFrameAB.frame_b then
t_b_0 = -Frames.resolve1(frame_b.R, torque);
frame_b.t = -torque;
elseif resolveInFrame == ResolveInFrameAB.world then
t_b_0 = -torque;
frame_b.t = Frames.resolve2(frame_b.R, t_b_0);
elseif resolveInFrame == ResolveInFrameAB.frame_resolve then
t_b_0 = -Frames.resolve1(frame_resolve.R, torque);
frame_b.t = Frames.resolve2(frame_b.R, t_b_0);
else
assert(false, "Wrong value for parameter resolveInFrame");
t_b_0 = zeros(3);
frame_b.t = zeros(3);
end if;
if resolveInFrame == ResolveInFrameAB.frame_a then
t_b_0 = -Frames.resolve1(frame_a.R, torque);
frame_b.t = Frames.resolve2(frame_b.R, t_b_0);
elseif resolveInFrame == ResolveInFrameAB.frame_b then
t_b_0 = -Frames.resolve1(frame_b.R, torque);
frame_b.t = -torque;
elseif resolveInFrame == ResolveInFrameAB.world then
t_b_0 = -torque;
frame_b.t = Frames.resolve2(frame_b.R, t_b_0);
elseif resolveInFrame == ResolveInFrameAB.frame_resolve then
t_b_0 = -Frames.resolve1(frame_resolve.R, torque);
frame_b.t = Frames.resolve2(frame_b.R, t_b_0);
else
assert(false, "Wrong value for parameter resolveInFrame");
t_b_0 = zeros(3);
frame_b.t = zeros(3);
end if;

// torque balance
zeros(3) = frame_a.t + Frames.resolve2(frame_a.R, t_b_0);
annotation (
Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{
100,100}}), graphics={
Expand Down
25 changes: 15 additions & 10 deletions Modelica/Mechanics/MultiBody/Interfaces/PartialForce.mo
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
within Modelica.Mechanics.MultiBody.Interfaces;
partial model PartialForce
"Base model for force elements (provide frame_b.f and frame_b.t in subclasses)"
"Base model for force elements, used for textual modeling, i.e., for elementary models"
extends PartialTwoFrames;

SI.Position r_rel_b[3]
"Position vector from origin of frame_a to origin of frame_b, resolved in frame_b";
Frames.Orientation R_rel
"Relative orientation object from frame_a to frame_b";
equation
// Determine relative position vector between frame_a and frame_b
// Determine relative position and orientation
r_rel_b = Frames.resolve2(frame_b.R, frame_b.r_0 - frame_a.r_0);
R_rel = Frames.relativeRotation(frame_a.R, frame_b.R);

// Force and torque balance between frame_a and frame_b
zeros(3) = frame_a.f + Frames.resolveRelative(frame_b.f, frame_b.R, frame_a.R);
zeros(3) = frame_a.t + Frames.resolveRelative(frame_b.t + cross(r_rel_b, frame_b.f), frame_b.R, frame_a.R);
zeros(3) = frame_a.f + Frames.resolve1(R_rel, frame_b.f);
zeros(3) = frame_a.t + Frames.resolve1(R_rel, frame_b.t + cross(r_rel_b, frame_b.f));

annotation (Documentation(info="<html>
<p>
All <strong>3-dimensional force</strong> and <strong>torque elements</strong>
should be based on this superclass.
All elementary <strong>3-dimensional force</strong> and
<strong>torque elements</strong> should be based on this superclass.
This model defines frame_a and frame_b, computes the relative
translation and rotation between the two frames and calculates
the cut-force and cut-torque at frame_a by a force and torque
balance from the cut-force and cut-torque at frame_b.
As a result, in a subclass, only the relationship between
the cut-force and cut-torque at frame_b has to be defined as
a function of the following relative quantities:
the cut-force and cut-torque at frame_b (i.e., frame_b.f and frame_b.t)
has to be defined as a function of the following relative quantities:
</p>
<blockquote><pre>
r_rel_b[3]: Position vector from origin of frame_a to origin
of frame_b, resolved in frame_b
R_rel : Relative orientation object to rotate from frame_a to frame_b
R_rel : Relative orientation object from frame_a to frame_b
</pre></blockquote>
<p>
Assume that force f = {100,0,0} should be applied on the body
Expand All @@ -42,7 +47,7 @@ the definition should be:
<strong>end</strong> Constant_x_Force;
</pre></blockquote>
<p>
Note, that frame_b.f and frame_b.t are flow variables and therefore
Note, that frame_b.f and frame_b.t are flow variables and, therefore,
the negative value of frame_b.f and frame_b.t is acting at the part
to which this force element is connected.
</p>
Expand Down