Mechanics package contains several classes implementing implementing an interactive damper, a set of interactive dampers, an interactive spring and a set of interactive springs.
| Name | Description |
|---|---|
| Damper | |
| Set of dampers | |
| Spring | |
| Set of springs |
VirtualLabBuilder.src.ViewElements.Drawables.Mechanics.Damper
This class inherits from the Drawable class.
Creates a damper.
The posistion of the two damper extremities (p1[:] and p2[:] variables) can be linked to the model variables.
| Type | Name | Default | Description |
|---|---|---|---|
| Real | d | 1/3 | Length of the damper fixed part divided by the damper length |
| Real | L1 | 0.02 | Distance from the wide to the narrow part of the damper |
| Real | L2 | 0.02 | Width of the narrow part of the damper |
| Integer | intX1Y1 | 0 | = 0 if the point (x1, y1) change in time and 0 otherwise |
| Integer | intX2Y2 | 0 | = 0 if the point (x2, y2) change in time and 0 otherwise |
| Color | color1[4] | {255,0,255,255} | The damper color changes form this color to color2 |
| Color | color2[4] | {249,204,202,255} | The damper color changes form this color to color1 |
| Type | Name | Description |
|---|---|---|
| Parent | pLeft | Connector of drawable components |
| Child | cLeft | Connector of drawable components |
model Damper "Damper"
extends Drawables.Drawable(numIntColor = 0, numInt = (intX1Y1*2+intX2Y2*2));
import Modelica.Utilities.*;
parameter Real d = 1/3
"Length of the damper fixed part divided by the damper length";
parameter Real L1 = 0.02
"Distance from the wide to the narrow part of the damper";
parameter Real L2 = 0.02 "Width of the narrow part of the damper";
parameter Integer intX1Y1 = 0
"= 0 if the point (x1, y1) change in time and 0 otherwise ";
parameter Integer intX2Y2 = 0
"= 0 if the point (x2, y2) change in time and 0 otherwise ";
parameter TypesDef.Color color1 = {255,0,255,255}
"The damper color changes form this color to color2";
parameter TypesDef.Color color2 = {249,204,202,255}
"The damper color changes form this color to color1";
input Real p1[2] "Position of the point (x1, y1)";
input Real p2[2] "Position of the point (x2, y2)";
initial algorithm
num :=Functions.processingFile(fComponent);
Functions.damper(fileName, "node"+String(pLeft.nodeReference), "node"+String(num),String(num),
d, L1, L2, p1[1], p2[1], p1[2], p2[2], intX1Y1, intX2Y2, color1, color2);
equation
algorithm
vert[numInt+1] :=-1;
colors[numIntColor+1] :=-1;
if (numInt==4) then
vert[1] :=p1[1];
vert[2] :=p2[1];
vert[3] :=p1[2];
vert[4] :=p2[2];
end if;
if (numInt == 2) then
if
(intX1Y1==1) then
vert[1] :=p1[1];
vert[2] :=p1[2];
else
vert[1] :=p2[1];
vert[2] :=p2[2];
end if;
end if;
end Damper;
VirtualLabBuilder.src.ViewElements.Drawables.Mechanics.DamperSet
Creates a set of dampers. The posistion of the two extremities of each damper (p1[:, :] and p2[:, :] variables) can be linked to the model variables.
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | N_dampers | 2 | Number of dampers |
| Real | d | 1/3 | length of the damper fixed part divided by the damper length |
| Real | L1 | 0.02 | distance from the wide to the narrow part of the damper |
| Real | L2 | 0.02 | width of the narrow part of the damper |
| Integer | intX1Y1 | 0 | = 0 if the point (x1, y1) change in time and 0 otherwise |
| Integer | intX2Y2 | 0 | = 0 if the point (x2, y2) change in time and 0 otherwise |
| Color | color1[4] | {255,0,255,255} | The damper color changes form this color to color2 |
| Color | color2[4] | {249,204,202,255} | The damper color changes form this color to color1 |
| Type | Name | Description |
|---|---|---|
| Parent | parent | Connector of the drawable elements |
| Child | child | Connector of the drawable elements |
model DamperSet "Set of dampers"
parameter Integer N_dampers = 2 "Number of dampers";
parameter Real d = 1/3
"length of the damper fixed part divided by the damper length";
parameter Real L1 = 0.02
"distance from the wide to the narrow part of the damper";
parameter Real L2 = 0.02 "width of the narrow part of the damper";
parameter Integer intX1Y1 = 0
"= 0 if the point (x1, y1) change in time and 0 otherwise ";
parameter Integer intX2Y2 = 0
"= 0 if the point (x2, y2) change in time and 0 otherwise ";
parameter TypesDef.Color color1 = {255,0,255,255}
"The damper color changes form this color to color2";
parameter TypesDef.Color color2 = {249,204,202,255}
"The damper color changes form this color to color1";
input Real p1[N_dampers, 2] "position of the point (x1, y1)";
input Real p2[N_dampers, 2] "position of the point (x2, y2)";
Damper dampers[N_dampers](each d = d, each L1 = L1, each L2 = L2, each intX1Y1 = intX1Y1, each
intX2Y2 = intX2Y2, each
color1 = color1, each
color2 = color2);
VirtualLabBuilder.src.Interfaces.Parent parent
"Connector of the drawable elements";
VirtualLabBuilder.src.Interfaces.Child child
"Connector of the drawable elements";
equation
connect(dampers[1].pLeft,parent);
connect(dampers[N_dampers].cLeft,child);
for i in 1:N_dampers-1 loop
connect(dampers[i].cLeft,dampers[i+1].pLeft);
end for;
for i in 1:N_dampers loop
dampers[i].p1 = p1[i,1:2];
dampers[i].p2 = p2[i,1:2];
end for;
end DamperSet;
VirtualLabBuilder.src.ViewElements.Drawables.Mechanics.Spring
This class inherits from the Drawable class.
Creates a spring.
The posistion of the two spring extremities (p1[:] and p2[:] variables) can be linked to the model variables.
| Type | Name | Default | Description |
|---|---|---|---|
| Real | d | 1/19 | length of the spring without picks divided by the damper length and two |
| Integer | N | 4 | pick number |
| Real | A | 0.05 | amplitude of the picks |
| Integer | intX1Y1 | 0 | = 0 if the point (x1, y1) change in time and 0 otherwise |
| Integer | intX2Y2 | 0 | = 0 if the point (x2, y2) change in time and 0 otherwise |
| Real | stroke | 2 | Stroke used to draw the lines |
| Color | lineColor[4] | {192,192,192,255} | Line Color |
| Type | Name | Description |
|---|---|---|
| Parent | pLeft | Connector of drawable components |
| Child | cLeft | Connector of drawable components |
model Spring "Spring"
extends Drawables.Drawable(numIntColor = 0, numInt = (intX1Y1*2+intX2Y2*2));
import Modelica.Utilities.*;
parameter Real d = 1/19
"length of the spring without picks divided by the damper length and two";
parameter Integer N = 4 "pick number";
parameter Real A = 0.05 "amplitude of the picks";
parameter Integer intX1Y1 = 0
"= 0 if the point (x1, y1) change in time and 0 otherwise ";
parameter Integer intX2Y2 = 0
"= 0 if the point (x2, y2) change in time and 0 otherwise ";
parameter Real stroke = 2 "Stroke used to draw the lines";
parameter TypesDef.Color lineColor = {192,192,192,255} "Line Color";
input Real p1[2] "position of the point (x1, y1)";
input Real p2[2] "position of the point (x2, y2)";
initial algorithm
num :=Functions.processingFile(fComponent);
Functions.spring(fileName, "node"+String(pLeft.nodeReference), "node"+String(num), String(num),
d, N, A, stroke, p1[1], p2[1], p1[2], p2[2], intX1Y1, intX2Y2, lineColor);
equation
algorithm
vert[numInt+1] :=-1;
colors[numIntColor+1] :=-1;
if (numInt==4) then
vert[1] :=p1[1];
vert[2] :=p2[1];
vert[3] :=p1[2];
vert[4] :=p2[2];
end if;
if (numInt == 2) then
if
(intX1Y1==1) then
vert[1] :=p1[1];
vert[2] :=p1[2];
else
vert[1] :=p2[1];
vert[2] :=p2[2];
end if;
end if;
end Spring;
VirtualLabBuilder.src.ViewElements.Drawables.Mechanics.SpringSet
Creates a set of dampers. The posistion of the two extremities of each spring (p1[:, :] and p2[:, :] variables) can be linked to the model variables.
| Type | Name | Default | Description |
|---|---|---|---|
| Integer | N_springs | 2 | Number of springs |
| Real | d | 1/19 | length of the spring without picks divided by the damper length and two |
| Integer | N | 4 | pick number |
| Real | A | 0.05 | amplitude of the picks |
| Integer | intX1Y1 | 0 | = 0 if the point (x1, y1) change in time and 0 otherwise |
| Integer | intX2Y2 | 0 | = 0 if the point (x2, y2) change in time and 0 otherwise |
| Real | stroke | 2 | Stroke used to draw the lines |
| Color | lineColor[4] | {192,192,192,255} | Line Color |
| Type | Name | Description |
|---|---|---|
| Parent | parent | Connector of the drawable elements |
| Child | child | Connector of the drawable elements |
model SpringSet "Set of springs"
parameter Integer N_springs = 2 "Number of springs";
parameter Real d = 1/19
"length of the spring without picks divided by the damper length and two";
parameter Integer N = 4 "pick number";
parameter Real A = 0.05 "amplitude of the picks";
parameter Integer intX1Y1 = 0
"= 0 if the point (x1, y1) change in time and 0 otherwise ";
parameter Integer intX2Y2 = 0
"= 0 if the point (x2, y2) change in time and 0 otherwise ";
parameter Real stroke = 2 "Stroke used to draw the lines";
parameter TypesDef.Color lineColor = {192,192,192,255} "Line Color";
input Real p1[N_springs,2] "position of the point (x1, y1)";
input Real p2[N_springs, 2] "position of the point (x2, y2)";
Spring springs[N_springs](each d = d, each N = N, each A = A, each intX1Y1 = intX1Y1, each
intX2Y2 = intX2Y2, each
stroke = stroke,
each lineColor = lineColor);
VirtualLabBuilder.src.Interfaces.Parent parent
"Connector of the drawable elements";
VirtualLabBuilder.src.Interfaces.Child child
"Connector of the drawable elements";
equation
connect(springs[1].pLeft,parent);
connect(springs[N_springs].cLeft,child);
for i in 1:N_springs-1 loop
connect(springs[i].cLeft,springs[i+1].pLeft);
end for;
for i in 1:N_springs loop
springs[i].p1 = p1[i,1:2];
springs[i].p2 = p2[i,1:2];
end for;
end SpringSet;