ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/integrators/DLM.cpp
Revision: 1883
Committed: Mon Dec 13 22:30:27 2004 UTC (19 years, 7 months ago) by tim
File size: 3496 byte(s)
Log Message:
MPI version is built

File Contents

# User Rev Content
1 tim 1820 /*
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     double sinAngle;
84     double cosAngle;
85     double angleSqr;
86     double angleSqrOver4;
87     double top, bottom;
88    
89     RotMat3x3d tempA(A); // initialize the tempA
90     Vector3d tempJ(0.0);
91    
92     RotMat3x3d rot = RotMat3x3d::identity(); // initalize rot as a unit matrix
93    
94     // use a small angle aproximation for sin and cosine
95    
96     angleSqr = angle * angle;
97     angleSqrOver4 = angleSqr / 4.0;
98     top = 1.0 - angleSqrOver4;
99     bottom = 1.0 + angleSqrOver4;
100    
101     cosAngle = top / bottom;
102     sinAngle = angle / bottom;
103    
104     rot(axes1, axes1) = cosAngle;
105     rot(axes2, axes2) = cosAngle;
106    
107     rot(axes1, axes2) = sinAngle;
108     rot(axes2, axes1) = -sinAngle;
109    
110     // rotate the momentum acoording to: ji[] = rot[][] * ji[]
111     ji = rot * ji;
112    
113     // rotate the Rotation matrix acording to:
114     // A[][] = A[][] * transpose(rot[][])
115     // transpose(A[][]) = transpose(A[][]) * transpose(rot[][])
116    
117     A = rot * A; //? A = A* rot.transpose();
118    
119     }
120    
121    
122     }

Properties

Name Value
svn:executable *