mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-12-22 04:13:33 +01:00
Changed float array to tuple in Coordinate
This commit is contained in:
parent
60e374eb03
commit
fde8ef7d8c
@ -63,7 +63,7 @@ let create ~indice ~expo ~coef ~center ~totAngMom =
|
||||
assert (Array.length expo > 0);
|
||||
let tmp =
|
||||
{ indice ; expo ; coef ; center ; totAngMom ; size=Array.length expo ; norm_coef = [||];
|
||||
powers = Angular_momentum.zkey_array (Kind_1 totAngMom) }
|
||||
powers = Angular_momentum.zkey_array (Angular_momentum.Kind_1 totAngMom) }
|
||||
in
|
||||
{ tmp with norm_coef = compute_norm_coef tmp }
|
||||
|
||||
|
@ -15,10 +15,11 @@ type t = {
|
||||
|
||||
exception Null_contribution
|
||||
|
||||
let create_array ?(cutoff=0.) p_a p_b =
|
||||
let log_cutoff =
|
||||
if (cutoff = 0.) then infinity
|
||||
else -. (log cutoff)
|
||||
let create_array ?cutoff p_a p_b =
|
||||
let cutoff, log_cutoff =
|
||||
match cutoff with
|
||||
| None -> -1., max_float
|
||||
| Some cutoff -> cutoff, -. (log cutoff)
|
||||
in
|
||||
|
||||
let center_ab = Coordinate.(
|
||||
|
2
Makefile
2
Makefile
@ -3,7 +3,7 @@
|
||||
INCLUDE_DIRS=Nuclei,Utils,Basis
|
||||
LIBS=
|
||||
PKGS=
|
||||
OCAMLCFLAGS="-g"
|
||||
OCAMLCFLAGS="-g -warn-error A"
|
||||
OCAMLBUILD=ocamlbuild -j 0 -cflags $(OCAMLCFLAGS) -lflags $(OCAMLCFLAGS) -Is $(INCLUDE_DIRS)
|
||||
MLLFILES=$(wildcard */*.mll) $(wildcard *.mll)
|
||||
MLYFILES=$(wildcard */*.mly) $(wildcard *.mly)
|
||||
|
@ -1,28 +1,28 @@
|
||||
type t =
|
||||
| Bohr of float array
|
||||
| Angstrom of float array
|
||||
| Bohr of (float * float * float)
|
||||
| Angstrom of (float * float * float)
|
||||
|
||||
let a0 = Constants.a0
|
||||
|
||||
let zero = Bohr [| 0. ; 0. ; 0. |]
|
||||
let zero = Bohr (0., 0., 0.)
|
||||
|
||||
let of_float_triplet (x,y,z) = function
|
||||
| `Bohr -> Bohr [|x;y;z|]
|
||||
| `Angstrom -> Angstrom [|x;y;z|]
|
||||
| `Bohr -> Bohr (x,y,z)
|
||||
| `Angstrom -> Angstrom (x,y,z)
|
||||
|
||||
let of_3_floats x y z =
|
||||
of_float_triplet (x,y,z)
|
||||
|
||||
let to_string y =
|
||||
let result x =
|
||||
(string_of_float x.(0))^" "^(string_of_float x.(1))^" "^(string_of_float x.(2))
|
||||
let to_string t =
|
||||
let result (x,y,z) =
|
||||
(string_of_float x)^" "^(string_of_float y)^" "^(string_of_float z)
|
||||
in
|
||||
match y with
|
||||
match t with
|
||||
| Bohr x -> (result x) ^ " Bohr"
|
||||
| Angstrom x -> (result x) ^ " Angstrom"
|
||||
|
||||
|
||||
let extract_float_array = function
|
||||
let extract_float_tuple = function
|
||||
| Bohr a
|
||||
| Angstrom a -> a
|
||||
|
||||
@ -30,16 +30,15 @@ let extract_float_array = function
|
||||
(** Linear algebra *)
|
||||
let (|.) s a =
|
||||
match a with
|
||||
| Bohr [|x;y;z|] -> Bohr [| s*.x; s*.y; s*.z |]
|
||||
| Angstrom [|x;y;z|] -> Angstrom [| s*.x; s*.y; s*.z |]
|
||||
| _ -> assert false
|
||||
| Bohr (x,y,z) -> Bohr ( s*.x, s*.y, s*.z )
|
||||
| Angstrom (x,y,z) -> Angstrom ( s*.x, s*.y, s*.z )
|
||||
|
||||
let to_Angstrom = function
|
||||
| Angstrom a -> Angstrom a
|
||||
| Bohr a -> Angstrom (a0 |. Bohr a |> extract_float_array)
|
||||
| Bohr a -> Angstrom (a0 |. Bohr a |> extract_float_tuple)
|
||||
|
||||
let to_Bohr = function
|
||||
| Angstrom a -> Bohr (1./.a0 |. Angstrom a |> extract_float_array)
|
||||
| Angstrom a -> Bohr (1./.a0 |. Angstrom a |> extract_float_tuple)
|
||||
| Bohr a -> Bohr a
|
||||
|
||||
let (|-), (|+) =
|
||||
@ -50,42 +49,39 @@ let (|-), (|+) =
|
||||
| (Angstrom a, Bohr b) -> op f (to_Bohr p) q
|
||||
| (Bohr a, Angstrom b) -> op f p (to_Bohr q)
|
||||
in
|
||||
(op (fun a b ->
|
||||
match a,b with
|
||||
| [|x;y;z|], [|x';y';z'|] -> [| x-.x'; y-.y'; z-.z' |]
|
||||
| _ -> assert false
|
||||
) ,
|
||||
op (fun a b ->
|
||||
match a,b with
|
||||
| [|x;y;z|], [|x';y';z'|] -> [| x+.x'; y+.y'; z+.z' |]
|
||||
| _ -> assert false
|
||||
)
|
||||
(op (fun (x,y,z) (x',y',z') -> ( x-.x', y-.y', z-.z' )) ,
|
||||
op (fun (x,y,z) (x',y',z') -> ( x+.x', y+.y', z+.z' ))
|
||||
)
|
||||
|
||||
|
||||
let dot p q =
|
||||
let f = function
|
||||
| Bohr [|x;y;z|], Bohr [|x';y';z'|] -> x*.x' +. y*.y' +. z*.z'
|
||||
| _ -> assert false
|
||||
in
|
||||
f (to_Bohr p, to_Bohr q)
|
||||
let rec dot p q =
|
||||
match (p,q) with
|
||||
| Bohr (x,y,z), Bohr (x',y',z') -> x*.x' +. y*.y' +. z*.z'
|
||||
| _ -> dot (to_Bohr p) (to_Bohr q)
|
||||
|
||||
|
||||
let norm u =
|
||||
sqrt @@ dot u u
|
||||
|
||||
|
||||
let rec to_float_array a =
|
||||
to_Bohr a |> extract_float_array
|
||||
let rec to_tuple a =
|
||||
to_Bohr a |> extract_float_tuple
|
||||
|
||||
let x a = (extract_float_array @@ to_Bohr a).(0)
|
||||
let y a = (extract_float_array @@ to_Bohr a).(1)
|
||||
let z a = (extract_float_array @@ to_Bohr a).(2)
|
||||
let x a =
|
||||
let (result, _, _) = extract_float_tuple @@ to_Bohr a in
|
||||
result
|
||||
|
||||
let y a =
|
||||
let (_, result, _) = extract_float_tuple @@ to_Bohr a in
|
||||
result
|
||||
|
||||
let z a =
|
||||
let (_, _, result) = extract_float_tuple @@ to_Bohr a in
|
||||
result
|
||||
|
||||
let coord a = function
|
||||
| 0 -> (extract_float_array @@ to_Bohr a).(0)
|
||||
| 1 -> (extract_float_array @@ to_Bohr a).(1)
|
||||
| 2 -> (extract_float_array @@ to_Bohr a).(2)
|
||||
| 0 -> x a
|
||||
| 1 -> y a
|
||||
| 2 -> z a
|
||||
| _ -> raise (Invalid_argument "Coordinate")
|
||||
|
||||
|
@ -1,18 +1,18 @@
|
||||
type t
|
||||
val to_Angstrom : t -> t
|
||||
val to_Bohr : t -> t
|
||||
val zero : t
|
||||
val of_float_triplet : float * float * float -> [< `Angstrom | `Bohr ] -> t
|
||||
val of_float_triplet : (float * float * float) -> [< `Angstrom | `Bohr ] -> t
|
||||
val of_3_floats : float -> float -> float -> [< `Angstrom | `Bohr ] -> t
|
||||
val ( |. ) : float -> t -> t
|
||||
val ( |- ) : t -> t -> t
|
||||
val ( |+ ) : t -> t -> t
|
||||
val dot : t -> t -> float
|
||||
val norm : t -> float
|
||||
val to_string : t -> string
|
||||
val to_tuple : t -> (float * float * float)
|
||||
val x : t -> float
|
||||
val y : t -> float
|
||||
val z : t -> float
|
||||
val coord : t -> int -> float
|
||||
val to_float_array : t -> float array
|
||||
val (|-) : t -> t -> t
|
||||
val (|+) : t -> t -> t
|
||||
val (|.) : float -> t -> t
|
||||
val dot : t -> t -> float
|
||||
val to_Angstrom : t -> t
|
||||
val to_Bohr : t -> t
|
||||
val norm : t -> float
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user