ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/integrators/DLM.cpp
Revision: 1820
Committed: Thu Dec 2 00:09:35 2004 UTC (19 years, 7 months ago) by tim
File size: 3513 byte(s)
Log Message:
NVE get built

File Contents

# Content
1 /*
2 * Copyright (C) 2000-2004 Object Oriented Parallel Simulation Engine (OOPSE) project
3 *
4 * Contact: oopse@oopse.org
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1
9 * of the License, or (at your option) any later version.
10 * All we ask is that proper credit is given for our work, which includes
11 * - but is not limited to - adding the above copyright notice to the beginning
12 * of your source code files, and to any copyright notice that you may distribute
13 * with programs based on this work.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 *
24 */
25
26 #include "DLM.hpp"
27
28 namespace oopse {
29
30 void DLM::doRotate(StuntDouble* sd, Vector3d& ji, double dt) {
31 double dt2 = 0.5 * dt;
32 double angle;
33
34 RotMat3x3d A = sd->getA();
35 Mat3x3d I = sd->getI();
36
37 // use the angular velocities to propagate the rotation matrix a full time step
38 if (sd->isLinear()) {
39
40 int i = sd->linearAxis();
41 int j = (i+1)%3;
42 int k = (i+2)%3;
43
44 angle = dt2 * ji[j] / I(j, j);
45 rotateStep( k, i, angle, ji, A );
46
47 angle = dt * ji[k] / I(k, k);
48 rotateStep( i, j, angle, ji, A);
49
50 angle = dt2 * ji[j] / I(j, j);
51 rotateStep( k, i, angle, ji, A );
52
53 } else {
54 // rotate about the x-axis
55 angle = dt2 * ji[0] / I(0, 0);
56 rotateStep( 1, 2, angle, ji, A );
57
58 // rotate about the y-axis
59 angle = dt2 * ji[1] / I(1, 1);
60 rotateStep( 2, 0, angle, ji, A );
61
62 // rotate about the z-axis
63 angle = dt * ji[2] / I(2, 2);
64 sd->addZangle(angle);
65 rotateStep( 0, 1, angle, ji, A);
66
67 // rotate about the y-axis
68 angle = dt2 * ji[1] / I(1, 1);
69 rotateStep( 2, 0, angle, ji, A );
70
71 // rotate about the x-axis
72 angle = dt2 * ji[0] / I(0, 0);
73 rotateStep( 1, 2, angle, ji, A );
74
75 }
76
77 sd->setA( A );
78 }
79
80
81 void DLM::rotateStep(int axes1, int axes2, double angle, Vector3d& ji, RotMat3x3d& A) {
82
83 int i, j, k;
84 double sinAngle;
85 double cosAngle;
86 double angleSqr;
87 double angleSqrOver4;
88 double top, bottom;
89
90 RotMat3x3d tempA(A); // initialize the tempA
91 Vector3d tempJ(0.0);
92
93 RotMat3x3d rot = RotMat3x3d::identity(); // initalize rot as a unit matrix
94
95 // use a small angle aproximation for sin and cosine
96
97 angleSqr = angle * angle;
98 angleSqrOver4 = angleSqr / 4.0;
99 top = 1.0 - angleSqrOver4;
100 bottom = 1.0 + angleSqrOver4;
101
102 cosAngle = top / bottom;
103 sinAngle = angle / bottom;
104
105 rot(axes1, axes1) = cosAngle;
106 rot(axes2, axes2) = cosAngle;
107
108 rot(axes1, axes2) = sinAngle;
109 rot(axes2, axes1) = -sinAngle;
110
111 // rotate the momentum acoording to: ji[] = rot[][] * ji[]
112 ji = rot * ji;
113
114 // rotate the Rotation matrix acording to:
115 // A[][] = A[][] * transpose(rot[][])
116 // transpose(A[][]) = transpose(A[][]) * transpose(rot[][])
117
118 A = rot * A; //? A = A* rot.transpose();
119
120 }
121
122
123 }

Properties

Name Value
svn:executable *