mirror of
https://gitlab.com/scemama/QCaml.git
synced 2025-01-09 20:48:16 +01:00
Cleaning
This commit is contained in:
parent
7b8be87bfc
commit
27d775614f
@ -1,6 +1,7 @@
|
|||||||
open Util
|
open Util
|
||||||
open Lacaml.D
|
open Lacaml.D
|
||||||
open Bigarray
|
open Bigarray
|
||||||
|
open Powers
|
||||||
open Coordinate
|
open Coordinate
|
||||||
|
|
||||||
let cutoff = Constants.cutoff
|
let cutoff = Constants.cutoff
|
||||||
@ -25,31 +26,45 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
map_1d map_2d np nq
|
map_1d map_2d np nq
|
||||||
=
|
=
|
||||||
|
|
||||||
let totAngMom_a = Angular_momentum.to_int totAngMom_a
|
let angMom_a = Powers.of_int_tuple angMom_a
|
||||||
and totAngMom_b = Angular_momentum.to_int totAngMom_b
|
and angMom_b = Powers.of_int_tuple angMom_b
|
||||||
and totAngMom_c = Angular_momentum.to_int totAngMom_c
|
and angMom_c = Powers.of_int_tuple angMom_c
|
||||||
and totAngMom_d = Angular_momentum.to_int totAngMom_d
|
and angMom_d = Powers.of_int_tuple angMom_d
|
||||||
|
in
|
||||||
|
let totAngMom_a = angMom_a.tot
|
||||||
|
and totAngMom_b = angMom_b.tot
|
||||||
|
and totAngMom_c = angMom_c.tot
|
||||||
|
and totAngMom_d = angMom_d.tot
|
||||||
|
in
|
||||||
|
|
||||||
|
let get_xyz angMom =
|
||||||
|
match angMom with
|
||||||
|
| { y=0 ; z=0 ; _ } -> X
|
||||||
|
| { z=0 ; _ } -> Y
|
||||||
|
| _ -> Z
|
||||||
in
|
in
|
||||||
|
|
||||||
(** Vertical recurrence relations *)
|
(** Vertical recurrence relations *)
|
||||||
let rec vrr0_v m angMom_a = function
|
let rec vrr0_v m angMom_a = function
|
||||||
| 0 -> Some zero_m_array.(m)
|
| 0 -> Some zero_m_array.(m)
|
||||||
| totAngMom_a ->
|
| totAngMom_a ->
|
||||||
let key = Zkey.of_int_tuple (Zkey.Three angMom_a)
|
let key = Zkey.of_int_tuple (Zkey.Three (Powers.to_int_tuple angMom_a))
|
||||||
in
|
in
|
||||||
|
|
||||||
try Zmap.find map_1d.(m) key with
|
try Zmap.find map_1d.(m) key with
|
||||||
| Not_found ->
|
| Not_found ->
|
||||||
let result =
|
let result =
|
||||||
let am, amm, amxyz, xyz =
|
try
|
||||||
match angMom_a with
|
let xyz = get_xyz angMom_a in
|
||||||
| (x,0,0) -> (x-1,0,0),(x-2,0,0), x-1, X
|
let am =
|
||||||
| (x,y,0) -> (x,y-1,0),(x,y-2,0), y-1, Y
|
try Powers.decr xyz angMom_a
|
||||||
| (x,y,z) -> (x,y,z-1),(x,y,z-2), z-1, Z
|
with Invalid_argument _ -> raise Exit
|
||||||
in
|
in
|
||||||
|
(*
|
||||||
if amxyz < 0 then
|
if amxyz < 0 then
|
||||||
None
|
raise Exit
|
||||||
else
|
else
|
||||||
|
*)
|
||||||
begin
|
begin
|
||||||
let cab = Coordinate.get xyz center_ab in
|
let cab = Coordinate.get xyz center_ab in
|
||||||
let v1_top, p1_top =
|
let v1_top, p1_top =
|
||||||
@ -61,45 +76,17 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
vrr0_v (m+1) am (totAngMom_a-1)
|
vrr0_v (m+1) am (totAngMom_a-1)
|
||||||
in
|
in
|
||||||
let v1_top2, p1_top2 =
|
let v1_top2, p1_top2 =
|
||||||
if amxyz < 1 then (None,None) else
|
try
|
||||||
|
(*
|
||||||
|
if amxyz < 1 then None, None else
|
||||||
|
*)
|
||||||
|
let amm = Powers.decr xyz am in
|
||||||
vrr0_v m amm (totAngMom_a-2),
|
vrr0_v m amm (totAngMom_a-2),
|
||||||
vrr0_v (m+1) amm (totAngMom_a-2)
|
vrr0_v (m+1) amm (totAngMom_a-2)
|
||||||
|
with Invalid_argument _ -> None, None
|
||||||
in
|
in
|
||||||
|
|
||||||
let result = Array.make_matrix np nq 0. in
|
let result = Array.make_matrix np nq 0. in
|
||||||
if amxyz < 1 then
|
|
||||||
begin
|
|
||||||
let p0 =
|
|
||||||
match p1_top with
|
|
||||||
| Some p1_top -> p1_top
|
|
||||||
| _ -> assert false
|
|
||||||
in
|
|
||||||
begin
|
|
||||||
match v1_top with
|
|
||||||
| None -> ()
|
|
||||||
| Some v0 ->
|
|
||||||
Array.iteri (fun l result_l ->
|
|
||||||
let f0 = -. expo_b.(l) *. expo_inv_p.(l) *. cab
|
|
||||||
and v0_l = v0.(l)
|
|
||||||
and result_l = result.(l)
|
|
||||||
in
|
|
||||||
Array.iteri (fun k v0_lk ->
|
|
||||||
result_l.(k) <- v0_lk *. f0) v0_l
|
|
||||||
) result
|
|
||||||
end;
|
|
||||||
Array.iteri (fun l result_l ->
|
|
||||||
let expo_inv_p_l = expo_inv_p.(l)
|
|
||||||
and center_pq_xyz_l = (center_pq xyz).(l)
|
|
||||||
and result_l = result.(l)
|
|
||||||
and p0_l = p0.(l)
|
|
||||||
in
|
|
||||||
Array.iteri (fun k p0_lk ->
|
|
||||||
result_l.(k) <- result_l.(k)
|
|
||||||
+. expo_inv_p_l *. center_pq_xyz_l.(k) *. p0_lk
|
|
||||||
) p0_l ) result
|
|
||||||
end
|
|
||||||
else
|
|
||||||
begin
|
|
||||||
let p0 =
|
let p0 =
|
||||||
match p1_top with
|
match p1_top with
|
||||||
| Some p1_top -> p1_top
|
| Some p1_top -> p1_top
|
||||||
@ -116,6 +103,20 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
Array.iteri (fun k v0_lk ->
|
Array.iteri (fun k v0_lk ->
|
||||||
result_l.(k) <- v0_lk *. f0) v0_l ) result
|
result_l.(k) <- v0_lk *. f0) v0_l ) result
|
||||||
end;
|
end;
|
||||||
|
let amxyz = Powers.get xyz am in
|
||||||
|
if amxyz < 1 then
|
||||||
|
Array.iteri (fun l result_l ->
|
||||||
|
let expo_inv_p_l = expo_inv_p.(l)
|
||||||
|
and center_pq_xyz_l = (center_pq xyz).(l)
|
||||||
|
and result_l = result.(l)
|
||||||
|
and p0_l = p0.(l)
|
||||||
|
in
|
||||||
|
Array.iteri (fun k p0_lk ->
|
||||||
|
result_l.(k) <- result_l.(k)
|
||||||
|
+. expo_inv_p_l *. center_pq_xyz_l.(k) *. p0_lk
|
||||||
|
) p0_l ) result
|
||||||
|
else
|
||||||
|
begin
|
||||||
let v1 =
|
let v1 =
|
||||||
match v1_top2 with
|
match v1_top2 with
|
||||||
| Some v1_top2 -> v1_top2
|
| Some v1_top2 -> v1_top2
|
||||||
@ -143,6 +144,7 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
end;
|
end;
|
||||||
Some result
|
Some result
|
||||||
end
|
end
|
||||||
|
with Exit -> None
|
||||||
in
|
in
|
||||||
Zmap.add map_1d.(m) key result;
|
Zmap.add map_1d.(m) key result;
|
||||||
result
|
result
|
||||||
@ -153,35 +155,17 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
| (i,0) -> vrr0_v m angMom_a totAngMom_a
|
| (i,0) -> vrr0_v m angMom_a totAngMom_a
|
||||||
| (_,_) ->
|
| (_,_) ->
|
||||||
|
|
||||||
let key = Zkey.of_int_tuple (Zkey.Six (angMom_a, angMom_c))
|
let key = Zkey.of_int_tuple (Zkey.Six Powers.(to_int_tuple angMom_a, to_int_tuple angMom_c))
|
||||||
in
|
in
|
||||||
|
|
||||||
try Zmap.find map_2d.(m) key with
|
try Zmap.find map_2d.(m) key with
|
||||||
| Not_found ->
|
| Not_found ->
|
||||||
let result =
|
let result =
|
||||||
begin
|
begin
|
||||||
let am, cm, cmm, axyz, cxyz, xyz =
|
let xyz = get_xyz angMom_c in
|
||||||
let (aax, aay, aaz) = angMom_a
|
let cm = Powers.decr xyz angMom_c in
|
||||||
and (acx, acy, acz) = angMom_c in
|
let axyz = Powers.get xyz angMom_a in
|
||||||
if (acz > 0) then
|
|
||||||
(aax, aay, aaz-1),
|
|
||||||
(acx, acy, acz-1),
|
|
||||||
(acx, acy, acz-2),
|
|
||||||
aaz, acz, Z
|
|
||||||
else if (acy > 0) then
|
|
||||||
(aax, aay-1,aaz),
|
|
||||||
(acx, acy-1,acz),
|
|
||||||
(acx, acy-2,acz),
|
|
||||||
aay,acy, Y
|
|
||||||
else
|
|
||||||
(aax-1,aay,aaz),
|
|
||||||
(acx-1,acy,acz),
|
|
||||||
(acx-2,acy,acz),
|
|
||||||
aax,acx, X
|
|
||||||
in
|
|
||||||
(*
|
|
||||||
let result = Array.make_matrix np nq 0. in
|
|
||||||
*)
|
|
||||||
let do_compute = ref false in
|
let do_compute = ref false in
|
||||||
let v1 =
|
let v1 =
|
||||||
let f = -. (Coordinate.get xyz center_cd) in
|
let f = -. (Coordinate.get xyz center_cd) in
|
||||||
@ -261,8 +245,16 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
end
|
end
|
||||||
in
|
in
|
||||||
|
|
||||||
|
let cxyz = Powers.get xyz angMom_c in
|
||||||
let p2 =
|
let p2 =
|
||||||
if cxyz < 2 then p1 else
|
try
|
||||||
|
let cmm =
|
||||||
|
try Powers.decr xyz cm
|
||||||
|
with Invalid_argument _ -> raise Exit
|
||||||
|
in
|
||||||
|
if Powers.get xyz cmm < 0 then
|
||||||
|
raise Exit;
|
||||||
|
|
||||||
let fcm = (float_of_int (cxyz-1)) *. 0.5 in
|
let fcm = (float_of_int (cxyz-1)) *. 0.5 in
|
||||||
let f1 =
|
let f1 =
|
||||||
Array.init nq (fun k ->
|
Array.init nq (fun k ->
|
||||||
@ -371,8 +363,15 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
done;
|
done;
|
||||||
Some v3
|
Some v3
|
||||||
end
|
end
|
||||||
|
with Exit -> p1
|
||||||
in
|
in
|
||||||
if (axyz < 1) || (cxyz < 1) then p2 else
|
try
|
||||||
|
let am =
|
||||||
|
try Powers.decr xyz angMom_a
|
||||||
|
with Invalid_argument _ -> raise Exit
|
||||||
|
in
|
||||||
|
if (axyz < 1) || (cxyz < 1) then
|
||||||
|
raise Exit;
|
||||||
let v =
|
let v =
|
||||||
vrr_v (m+1) am cm (totAngMom_a-1) (totAngMom_c-1)
|
vrr_v (m+1) am cm (totAngMom_a-1) (totAngMom_c-1)
|
||||||
in
|
in
|
||||||
@ -397,6 +396,7 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
done;
|
done;
|
||||||
Some p2
|
Some p2
|
||||||
end
|
end
|
||||||
|
with Exit -> p2
|
||||||
end
|
end
|
||||||
in Zmap.add map_2d.(m) key result;
|
in Zmap.add map_2d.(m) key result;
|
||||||
result
|
result
|
||||||
@ -422,13 +422,8 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
| 1 ->
|
| 1 ->
|
||||||
let (aax, aay, aaz) = angMom_a in
|
let xyz = get_xyz angMom_b in
|
||||||
let ap, xyz =
|
let ap = Powers.incr xyz angMom_a in
|
||||||
match angMom_b with
|
|
||||||
| (_,_,1) -> (aax,aay,aaz+1), Z
|
|
||||||
| (_,1,_) -> (aax,aay+1,aaz), Y
|
|
||||||
| (_,_,_) -> (aax+1,aay,aaz), X
|
|
||||||
in
|
|
||||||
let f = Coordinate.get xyz center_ab in
|
let f = Coordinate.get xyz center_ab in
|
||||||
let v1 =
|
let v1 =
|
||||||
match vrr_v 0 ap angMom_c (totAngMom_a+1) totAngMom_c with
|
match vrr_v 0 ap angMom_c (totAngMom_a+1) totAngMom_c with
|
||||||
@ -443,20 +438,13 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
in
|
in
|
||||||
v1 +. v2 *. f
|
v1 +. v2 *. f
|
||||||
| _ ->
|
| _ ->
|
||||||
let (aax, aay, aaz) = angMom_a
|
let xyz = get_xyz angMom_b in
|
||||||
and (abx, aby, abz) = angMom_b in
|
let bxyz = Powers.get xyz angMom_b in
|
||||||
let bxyz, xyz =
|
|
||||||
match angMom_b with
|
|
||||||
| (0,0,_) -> abz, Z
|
|
||||||
| (0,_,_) -> aby, Y
|
|
||||||
| _ -> abx, X
|
|
||||||
in
|
|
||||||
if (bxyz < 1) then 0. else
|
if (bxyz < 1) then 0. else
|
||||||
let ap, bm =
|
let ap = Powers.incr xyz angMom_a in
|
||||||
match xyz with
|
let bm =
|
||||||
| X -> (aax+1,aay,aaz),(abx-1,aby,abz)
|
try Powers.decr xyz angMom_b
|
||||||
| Y -> (aax,aay+1,aaz),(abx,aby-1,abz)
|
with Invalid_argument _ -> raise Exit
|
||||||
| Z -> (aax,aay,aaz+1),(abx,aby,abz-1)
|
|
||||||
in
|
in
|
||||||
|
|
||||||
let h1 =
|
let h1 =
|
||||||
@ -482,13 +470,11 @@ let hvrr_two_e_vector (angMom_a, angMom_b, angMom_c, angMom_d)
|
|||||||
else
|
else
|
||||||
hrr0_v angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c
|
hrr0_v angMom_a angMom_b angMom_c totAngMom_a totAngMom_b totAngMom_c
|
||||||
| (_,_) ->
|
| (_,_) ->
|
||||||
let (acx, acy, acz) = angMom_c
|
let xyz = get_xyz angMom_d in
|
||||||
and (adx, ady, adz) = angMom_d in
|
let cp = Powers.incr xyz angMom_c in
|
||||||
let cp, dm, xyz =
|
let dm =
|
||||||
match angMom_d with
|
try Powers.decr xyz angMom_d
|
||||||
| (_,0,0) -> (acx+1, acy, acz), (adx-1, ady, adz), X
|
with Invalid_argument _ -> raise Exit
|
||||||
| (_,_,0) -> (acx, acy+1, acz), (adx, ady-1, adz), Y
|
|
||||||
| _ -> (acx, acy, acz+1), (adx, ady, adz-1), Z
|
|
||||||
in
|
in
|
||||||
let h1 =
|
let h1 =
|
||||||
hrr_v angMom_a angMom_b cp dm totAngMom_a totAngMom_b (totAngMom_c+1) (totAngMom_d-1)
|
hrr_v angMom_a angMom_b cp dm totAngMom_a totAngMom_b (totAngMom_c+1) (totAngMom_d-1)
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
exception AngularMomentumError of string
|
|
||||||
type t = S | P | D | F | G | H | I | J | K | L | M | N | O
|
|
||||||
val of_char : char -> t
|
|
||||||
val to_string : t -> string
|
|
||||||
val to_char : t -> char
|
|
||||||
val to_int : t -> int
|
|
||||||
val of_int : int -> t
|
|
||||||
type kind =
|
|
||||||
| Singlet of t
|
|
||||||
| Doublet of (t*t)
|
|
||||||
| Triplet of (t*t*t)
|
|
||||||
| Quartet of (t*t*t*t)
|
|
||||||
|
|
||||||
val n_functions : t -> int
|
|
||||||
val zkey_array : kind -> Zkey.t array
|
|
39
Utils/Powers.ml
Normal file
39
Utils/Powers.ml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
type t = { x: int ; y : int ; z : int ; tot : int }
|
||||||
|
|
||||||
|
let of_int_tuple t =
|
||||||
|
let result =
|
||||||
|
match t with
|
||||||
|
| (x,y,z) -> { x ; y ; z ; tot=x+y+z }
|
||||||
|
in
|
||||||
|
assert (result.tot >= 0);
|
||||||
|
result
|
||||||
|
|
||||||
|
let to_int_tuple { x ; y ; z ; _ } = (x,y,z)
|
||||||
|
|
||||||
|
let get coord t =
|
||||||
|
match coord with
|
||||||
|
| Coordinate.X -> t.x
|
||||||
|
| Coordinate.Y -> t.y
|
||||||
|
| Coordinate.Z -> t.z
|
||||||
|
|
||||||
|
let incr coord t =
|
||||||
|
match coord with
|
||||||
|
| Coordinate.X -> { t with x = t.x+1 ; tot = t.tot+1 }
|
||||||
|
| Coordinate.Y -> { t with y = t.y+1 ; tot = t.tot+1 }
|
||||||
|
| Coordinate.Z -> { t with z = t.z+1 ; tot = t.tot+1 }
|
||||||
|
|
||||||
|
let decr coord t =
|
||||||
|
(*
|
||||||
|
let test _ = ()
|
||||||
|
*)
|
||||||
|
let test x =
|
||||||
|
if x < 1 then
|
||||||
|
invalid_arg "Angular_momentum.Powers.decr";
|
||||||
|
in
|
||||||
|
match coord with
|
||||||
|
| Coordinate.X -> (test t.x ; { t with x = t.x-1 ; tot = t.tot-1 })
|
||||||
|
| Coordinate.Y -> (test t.y ; { t with y = t.y-1 ; tot = t.tot-1 })
|
||||||
|
| Coordinate.Z -> (test t.z ; { t with z = t.z-1 ; tot = t.tot-1 })
|
||||||
|
|
||||||
|
|
||||||
|
|
7
Utils/Powers.mli
Normal file
7
Utils/Powers.mli
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
type t = private { x: int ; y : int ; z : int ; tot : int }
|
||||||
|
val of_int_tuple : int * int * int -> t
|
||||||
|
val to_int_tuple : t -> int * int * int
|
||||||
|
val get : Coordinate.axis -> t -> int
|
||||||
|
val incr : Coordinate.axis -> t -> t
|
||||||
|
val decr : Coordinate.axis -> t -> t
|
||||||
|
|
Loading…
Reference in New Issue
Block a user