mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
applications/test/rigidBodyDynamics/pendulum: Cleanup
This commit is contained in:
@ -1,3 +1,3 @@
|
|||||||
pendulum.C
|
pendulum.C
|
||||||
|
|
||||||
EXE = $(FOAM_USER_APPBIN)/pendulum
|
EXE = $(FOAM_USER_APPBIN)/Test-pendulum
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
bodies
|
bodies0
|
||||||
{
|
{
|
||||||
pendulum
|
pendulum
|
||||||
{
|
{
|
||||||
@ -15,7 +15,7 @@ bodies
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bodies0
|
bodies
|
||||||
{
|
{
|
||||||
hinge
|
hinge
|
||||||
{
|
{
|
||||||
|
|||||||
@ -81,16 +81,15 @@ int main(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Create the pendulum model from dictionary
|
// Create the pendulum model from dictionary
|
||||||
rigidBodyModel pendulum1(dictionary(IFstream("pendulum")()));
|
rigidBodyModel pendulum(dictionary(IFstream("pendulum")()));
|
||||||
rigidBodyModel pendulum = pendulum1;
|
|
||||||
|
|
||||||
Info<< pendulum << endl;
|
Info<< pendulum << endl;
|
||||||
|
|
||||||
// Create the joint-space state fields
|
// Create the joint-space state fields
|
||||||
scalarField q(pendulum.nDoF(), Zero);
|
scalarField q(pendulum.nDoF(), Zero);
|
||||||
scalarField w(pendulum.nw(), Zero);
|
scalarField w(pendulum.nw(), Zero);
|
||||||
scalarField qdot(pendulum.nDoF(), Zero);
|
scalarField qDot(pendulum.nDoF(), Zero);
|
||||||
scalarField qddot(pendulum.nDoF(), Zero);
|
scalarField qDdot(pendulum.nDoF(), Zero);
|
||||||
scalarField tau(pendulum.nDoF(), Zero);
|
scalarField tau(pendulum.nDoF(), Zero);
|
||||||
|
|
||||||
// Set the angle of the pendulum to 0.3rad
|
// Set the angle of the pendulum to 0.3rad
|
||||||
@ -104,20 +103,20 @@ int main(int argc, char *argv[])
|
|||||||
scalar deltaT = 0.01;
|
scalar deltaT = 0.01;
|
||||||
for (scalar t=0; t<4.1; t+=deltaT)
|
for (scalar t=0; t<4.1; t+=deltaT)
|
||||||
{
|
{
|
||||||
qdot += 0.5*deltaT*qddot;
|
qDot += 0.5*deltaT*qDdot;
|
||||||
q += deltaT*qdot;
|
q += deltaT*qDot;
|
||||||
|
|
||||||
pendulum.forwardDynamics
|
pendulum.forwardDynamics
|
||||||
(
|
(
|
||||||
q,
|
q,
|
||||||
w,
|
w,
|
||||||
qdot,
|
qDot,
|
||||||
tau,
|
tau,
|
||||||
Field<spatialVector>(),
|
Field<spatialVector>(),
|
||||||
qddot
|
qDdot
|
||||||
);
|
);
|
||||||
|
|
||||||
qdot += 0.5*deltaT*qddot;
|
qDot += 0.5*deltaT*qDdot;
|
||||||
|
|
||||||
Info<< "Time " << t << "s, angle = " << q[0] << "rad" << endl;
|
Info<< "Time " << t << "s, angle = " << q[0] << "rad" << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user