4.1 Mathematical Pendulum
137
Fig. 4.6 Series of graphs of the damped oscillations of a mathematical pendulum in a viscous
medium with a viscosity coefficient of 0.5, 1.0, and 1.5 Ns/m
Addition: complete code for accurate and approximate models
model PendulumViz
constant Real pi = 3.1416 ”Pi”;
constant Real g(unit = ”m/s2”) = 9.81
”gravitational acceleration”;
parameter Real l(unit = ”m”) = 10
”length of the thread”;
parameter Real rad(unit = ”m”) = 0.5 ”radius of the bob”;
Real theta(unit = ”rad”, start = pi / 3)
”angular displacement”;
Real omega(unit = ”rad/s”, start = 0) ”angular velocity”;
Real x(unit = ”m”) ”horizontal displacement of the bob”;
Real y(unit = ”m”) ”vertical displacement of the bob”;
Real theta1(unit = ”rad”, start = pi / 3)
”angular displacement1”;
Real omega1(unit = ”rad/s”, start = 0) ”angular velocity1”;
Real x1(unit = ”m”) ”horizontal displacement of the bob1”;
Real y1(unit = ”m”) ”vertical displacement of the bob1”;
/*visualization objects*/
Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape
bob(shapeType = ”sphere”, length = 2 * rad, width =
2 * rad, height = 2 * rad, r = {x, y, 0}, r_shape =
{-rad, 0, 0}, color = {0, 50, 255});
Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape
137
Fig. 4.6 Series of graphs of the damped oscillations of a mathematical pendulum in a viscous
medium with a viscosity coefficient of 0.5, 1.0, and 1.5 Ns/m
Addition: complete code for accurate and approximate models
model PendulumViz
constant Real pi = 3.1416 ”Pi”;
constant Real g(unit = ”m/s2”) = 9.81
”gravitational acceleration”;
parameter Real l(unit = ”m”) = 10
”length of the thread”;
parameter Real rad(unit = ”m”) = 0.5 ”radius of the bob”;
Real theta(unit = ”rad”, start = pi / 3)
”angular displacement”;
Real omega(unit = ”rad/s”, start = 0) ”angular velocity”;
Real x(unit = ”m”) ”horizontal displacement of the bob”;
Real y(unit = ”m”) ”vertical displacement of the bob”;
Real theta1(unit = ”rad”, start = pi / 3)
”angular displacement1”;
Real omega1(unit = ”rad/s”, start = 0) ”angular velocity1”;
Real x1(unit = ”m”) ”horizontal displacement of the bob1”;
Real y1(unit = ”m”) ”vertical displacement of the bob1”;
/*visualization objects*/
Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape
bob(shapeType = ”sphere”, length = 2 * rad, width =
2 * rad, height = 2 * rad, r = {x, y, 0}, r_shape =
{-rad, 0, 0}, color = {0, 50, 255});
Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape
