3
* $Date: 2007-01-04 18:46:10 +0100 (Thu, 04 Jan 2007) $
6
* Copyright (C) 2001-2007 The Chemistry Development Kit (CDK) project
8
* Contact: cdk-devel@lists.sf.net
10
* This program is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU Lesser General Public License
12
* as published by the Free Software Foundation; either version 2.1
13
* of the License, or (at your option) any later version.
14
* All we ask is that proper credit is given for our work, which includes
15
* - but is not limited to - adding the above copyright notice to the beginning
16
* of your source code files, and to any copyright notice that you may distribute
17
* with programs based on this work.
19
* This program is distributed in the hope that it will be useful,
20
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
* GNU Lesser General Public License for more details.
24
* You should have received a copy of the GNU Lesser General Public License
25
* along with this program; if not, write to the Free Software
26
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
29
package org.openscience.cdk.math.qm;
31
import org.openscience.cdk.math.Complex;
32
import org.openscience.cdk.math.IMatrix;
33
import org.openscience.cdk.math.Matrix;
34
import org.openscience.cdk.math.Vector;
37
* This class is used to calculate angular momentum states
39
* @author Stephan Michels <stephan@vern.chem.tu-berlin.de>
40
* @cdk.created 2001-07-22
42
public class AngularMomentum {
47
public AngularMomentum(double J)
50
size = (int)Math.round(J*2.0+1.0);
51
basis = new Matrix(size,size);
55
basis.matrix[i][j] = 0d;
57
basis.matrix[i][i] = 1d;
61
* Calculates the Ix operator
63
public IMatrix getIx()
65
return (new IMatrix(getIplus().add(getIminus()))).mul(new Complex(0.5,0d));
69
* Calculates the Iy operator
71
public IMatrix getIy()
73
return (new IMatrix(getIplus().sub(getIminus()))).mul(new Complex(0d,1d)).mul(new Complex(0.5,0d));
77
* Calculates the Iz operator
79
public IMatrix getIz()
81
IMatrix Iz = new IMatrix(size,size);
86
Iz.realmatrix[i][j] = 0d;
87
Iz.imagmatrix[i][j] = 0d;
91
Iz.realmatrix[i][i] = J-i;
92
Iz.imagmatrix[i][i] = J-i;
98
* Calculates the I+ operator
100
public Matrix getIplus()
102
Matrix Iplus = new Matrix(size,size);
104
for(i=0; i<size; i++)
105
for(j=0; j<size; j++)
106
Iplus.matrix[i][j] = 0d;
107
for(i=1; i<size; i++)
108
Iplus.matrix[i-1][i] = Math.sqrt(J*J+J-(J-i+1)*(J-i+1)+(J-i+1));
113
* Calculates the I- operator
115
public Matrix getIminus()
117
Matrix Iminus = new Matrix(size,size);
119
for(i=0; i<size; i++)
120
for(j=0; j<size; j++)
121
Iminus.matrix[i][j] = 0d;
122
for(i=1; i<size; i++)
123
Iminus.matrix[i][i-1] = Math.sqrt(J*J+J-(J-i)*(J-i)-(J-i));
128
* Calculates a spin vector by a direction specified by theta and phi
130
public Vector getSpinVector(double theta, double phi)
132
Vector spinvector = new Vector(3);
133
spinvector.vector[0] = Math.sin(theta)*Math.cos(phi);
134
spinvector.vector[1] = Math.sin(theta)*Math.sin(phi);
135
spinvector.vector[2] = Math.cos(phi);