Some fixes

This commit is contained in:
2026-03-08 23:43:57 +01:00
parent 3bb0a04d4c
commit cc906cbd23
4 changed files with 138 additions and 10 deletions

View File

@@ -11,7 +11,7 @@ package BondGraphLib2D
parameter Real s[N] = fill(1.0, N)
"Bond orientation signs used in the effort balance";
BondPort P[N] "Power ports" annotation(
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {0, 80}, extent = {{-10, -10}, {10, 10}})));
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(extent = {{-10, -10}, {10, 10}})));
Real f[2];
equation
// Efforts sum to zero, with signs from bond directions
@@ -33,7 +33,7 @@ package BondGraphLib2D
parameter Real s[N] = fill(1.0, N)
"Bond orientation signs used in the effort balance";
BondPort P[N] "Power ports" annotation(
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {0, 80}, extent = {{-10, -10}, {10, 10}})));
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(extent = {{-10, -10}, {10, 10}})));
Real e[2];
equation
// Flows sum to zero, with signs from bond directions
@@ -52,7 +52,7 @@ package BondGraphLib2D
partial model OnePortPassive "One-port passive 2D multibond element"
BondPort p "Generic power port" annotation(
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {0, 80}, extent = {{-10, -10}, {10, 10}})));
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(extent = {{-10, -10}, {10, 10}})));
end OnePortPassive;
partial model OnePortEnergetic "One-port 2D multibond storage element"
@@ -193,8 +193,47 @@ package BondGraphLib2D
Icon(graphics = {Text(extent = {{-60, 100}, {60, -100}}, textString = "mGY", textStyle = {TextStyle.Bold, TextStyle.UnderLine}) }));
end mGY;
package TransRotUtils
model mTFrot2lin
BondGraphLib.BondPort pR annotation(
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}})));
BondPort pT annotation(
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {80, 0}, extent = {{-10, -10}, {10, 10}})));
parameter Real r_body[2] = {1,0};
protected
Real B[2];
equation
B = {-r_body[2], r_body[1]};
pT.f = B * pR.f;
pR.e = B[1]*pT.e[1] + B[2]*pT.e[2];
annotation(
Icon(graphics = {Text(extent = {{-70, 100}, {70, -100}}, textString = "rlTF", textStyle = {TextStyle.Bold, TextStyle.UnderLine})}));
end mTFrot2lin;
model rTF
BondPort p1 "Port 1" annotation(
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {-80, 0}, extent = {{-10, -10}, {10, 10}})));
BondPort p2 "Port 2" annotation(
Placement(transformation(origin = {-44, 18}, extent = {{-10, -10}, {10, 10}}), iconTransformation(origin = {80, 0}, extent = {{-10, -10}, {10, 10}})));
Modelica.Blocks.Interfaces.RealInput phi "angle" annotation(
Placement(transformation(origin = {-8, -64}, extent = {{-20, -20}, {20, 20}}), iconTransformation(origin = {0, -78}, extent = {{-8, -8}, {8, 8}}, rotation = 90)));
protected
Real R[2,2];
equation
R = [cos(phi), -sin(phi);
sin(phi), cos(phi)];
p1.e = R * p2.e;
transpose(R) * p1.f = p2.f;
annotation(
Diagram(graphics),
Icon(graphics = {Text(extent = {{-60, 100}, {60, -100}}, textString = "rTF", textStyle = {TextStyle.Bold, TextStyle.UnderLine}) }));
end rTF;
end TransRotUtils;
annotation(
Icon(graphics = {Text(origin = {50, 0}, extent = {{-50, 100}, {50, -100}}, textString = "R", textStyle = {TextStyle.Bold}), Line(origin = {-45.22, 20.19}, points = {{-58.7774, -20.1934}, {21.2226, -20.1934}, {-38.7774, 19.8066}}, thickness = 5), Line(origin = {-9.81, -8.19}, points = {{-10.1934, 48.1934}, {-10.1934, -31.8066}}, thickness = 5), Line(origin = {-78, 16}, points = {{-26, 0}, {30, 0}}, thickness = 5)}),
uses(Modelica(version = "4.1.0")),
Diagram(graphics));
end BondGraphLib2D;
end BondGraphLib2D;