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);
|
assert (Array.length expo > 0);
|
||||||
let tmp =
|
let tmp =
|
||||||
{ indice ; expo ; coef ; center ; totAngMom ; size=Array.length expo ; norm_coef = [||];
|
{ 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
|
in
|
||||||
{ tmp with norm_coef = compute_norm_coef tmp }
|
{ tmp with norm_coef = compute_norm_coef tmp }
|
||||||
|
|
||||||
|
@ -15,10 +15,11 @@ type t = {
|
|||||||
|
|
||||||
exception Null_contribution
|
exception Null_contribution
|
||||||
|
|
||||||
let create_array ?(cutoff=0.) p_a p_b =
|
let create_array ?cutoff p_a p_b =
|
||||||
let log_cutoff =
|
let cutoff, log_cutoff =
|
||||||
if (cutoff = 0.) then infinity
|
match cutoff with
|
||||||
else -. (log cutoff)
|
| None -> -1., max_float
|
||||||
|
| Some cutoff -> cutoff, -. (log cutoff)
|
||||||
in
|
in
|
||||||
|
|
||||||
let center_ab = Coordinate.(
|
let center_ab = Coordinate.(
|
||||||
|
2
Makefile
2
Makefile
@ -3,7 +3,7 @@
|
|||||||
INCLUDE_DIRS=Nuclei,Utils,Basis
|
INCLUDE_DIRS=Nuclei,Utils,Basis
|
||||||
LIBS=
|
LIBS=
|
||||||
PKGS=
|
PKGS=
|
||||||
OCAMLCFLAGS="-g"
|
OCAMLCFLAGS="-g -warn-error A"
|
||||||
OCAMLBUILD=ocamlbuild -j 0 -cflags $(OCAMLCFLAGS) -lflags $(OCAMLCFLAGS) -Is $(INCLUDE_DIRS)
|
OCAMLBUILD=ocamlbuild -j 0 -cflags $(OCAMLCFLAGS) -lflags $(OCAMLCFLAGS) -Is $(INCLUDE_DIRS)
|
||||||
MLLFILES=$(wildcard */*.mll) $(wildcard *.mll)
|
MLLFILES=$(wildcard */*.mll) $(wildcard *.mll)
|
||||||
MLYFILES=$(wildcard */*.mly) $(wildcard *.mly)
|
MLYFILES=$(wildcard */*.mly) $(wildcard *.mly)
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
type t =
|
type t =
|
||||||
| Bohr of float array
|
| Bohr of (float * float * float)
|
||||||
| Angstrom of float array
|
| Angstrom of (float * float * float)
|
||||||
|
|
||||||
let a0 = Constants.a0
|
let a0 = Constants.a0
|
||||||
|
|
||||||
let zero = Bohr [| 0. ; 0. ; 0. |]
|
let zero = Bohr (0., 0., 0.)
|
||||||
|
|
||||||
let of_float_triplet (x,y,z) = function
|
let of_float_triplet (x,y,z) = function
|
||||||
| `Bohr -> Bohr [|x;y;z|]
|
| `Bohr -> Bohr (x,y,z)
|
||||||
| `Angstrom -> Angstrom [|x;y;z|]
|
| `Angstrom -> Angstrom (x,y,z)
|
||||||
|
|
||||||
let of_3_floats x y z =
|
let of_3_floats x y z =
|
||||||
of_float_triplet (x,y,z)
|
of_float_triplet (x,y,z)
|
||||||
|
|
||||||
let to_string y =
|
let to_string t =
|
||||||
let result x =
|
let result (x,y,z) =
|
||||||
(string_of_float x.(0))^" "^(string_of_float x.(1))^" "^(string_of_float x.(2))
|
(string_of_float x)^" "^(string_of_float y)^" "^(string_of_float z)
|
||||||
in
|
in
|
||||||
match y with
|
match t with
|
||||||
| Bohr x -> (result x) ^ " Bohr"
|
| Bohr x -> (result x) ^ " Bohr"
|
||||||
| Angstrom x -> (result x) ^ " Angstrom"
|
| Angstrom x -> (result x) ^ " Angstrom"
|
||||||
|
|
||||||
|
|
||||||
let extract_float_array = function
|
let extract_float_tuple = function
|
||||||
| Bohr a
|
| Bohr a
|
||||||
| Angstrom a -> a
|
| Angstrom a -> a
|
||||||
|
|
||||||
@ -30,16 +30,15 @@ let extract_float_array = function
|
|||||||
(** Linear algebra *)
|
(** Linear algebra *)
|
||||||
let (|.) s a =
|
let (|.) s a =
|
||||||
match a with
|
match a with
|
||||||
| Bohr [|x;y;z|] -> Bohr [| s*.x; s*.y; s*.z |]
|
| Bohr (x,y,z) -> Bohr ( s*.x, s*.y, s*.z )
|
||||||
| Angstrom [|x;y;z|] -> Angstrom [| s*.x; s*.y; s*.z |]
|
| Angstrom (x,y,z) -> Angstrom ( s*.x, s*.y, s*.z )
|
||||||
| _ -> assert false
|
|
||||||
|
|
||||||
let to_Angstrom = function
|
let to_Angstrom = function
|
||||||
| Angstrom a -> Angstrom a
|
| 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
|
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
|
| Bohr a -> Bohr a
|
||||||
|
|
||||||
let (|-), (|+) =
|
let (|-), (|+) =
|
||||||
@ -50,42 +49,39 @@ let (|-), (|+) =
|
|||||||
| (Angstrom a, Bohr b) -> op f (to_Bohr p) q
|
| (Angstrom a, Bohr b) -> op f (to_Bohr p) q
|
||||||
| (Bohr a, Angstrom b) -> op f p (to_Bohr q)
|
| (Bohr a, Angstrom b) -> op f p (to_Bohr q)
|
||||||
in
|
in
|
||||||
(op (fun a b ->
|
(op (fun (x,y,z) (x',y',z') -> ( x-.x', y-.y', z-.z' )) ,
|
||||||
match a,b with
|
op (fun (x,y,z) (x',y',z') -> ( x+.x', y+.y', z+.z' ))
|
||||||
| [|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
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
let dot p q =
|
let rec dot p q =
|
||||||
let f = function
|
match (p,q) with
|
||||||
| Bohr [|x;y;z|], Bohr [|x';y';z'|] -> x*.x' +. y*.y' +. z*.z'
|
| Bohr (x,y,z), Bohr (x',y',z') -> x*.x' +. y*.y' +. z*.z'
|
||||||
| _ -> assert false
|
| _ -> dot (to_Bohr p) (to_Bohr q)
|
||||||
in
|
|
||||||
f (to_Bohr p, to_Bohr q)
|
|
||||||
|
|
||||||
|
|
||||||
let norm u =
|
let norm u =
|
||||||
sqrt @@ dot u u
|
sqrt @@ dot u u
|
||||||
|
|
||||||
|
|
||||||
let rec to_float_array a =
|
let rec to_tuple a =
|
||||||
to_Bohr a |> extract_float_array
|
to_Bohr a |> extract_float_tuple
|
||||||
|
|
||||||
let x a = (extract_float_array @@ to_Bohr a).(0)
|
let x a =
|
||||||
let y a = (extract_float_array @@ to_Bohr a).(1)
|
let (result, _, _) = extract_float_tuple @@ to_Bohr a in
|
||||||
let z a = (extract_float_array @@ to_Bohr a).(2)
|
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
|
let coord a = function
|
||||||
| 0 -> (extract_float_array @@ to_Bohr a).(0)
|
| 0 -> x a
|
||||||
| 1 -> (extract_float_array @@ to_Bohr a).(1)
|
| 1 -> y a
|
||||||
| 2 -> (extract_float_array @@ to_Bohr a).(2)
|
| 2 -> z a
|
||||||
| _ -> raise (Invalid_argument "Coordinate")
|
| _ -> raise (Invalid_argument "Coordinate")
|
||||||
|
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
type t
|
type t
|
||||||
val zero : t
|
|
||||||
val of_float_triplet : float * float * float -> [< `Angstrom | `Bohr ] -> t
|
|
||||||
val of_3_floats : float -> float -> float -> [< `Angstrom | `Bohr ] -> t
|
|
||||||
val to_string : t -> string
|
|
||||||
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_Angstrom : t -> t
|
||||||
val to_Bohr : t -> t
|
val to_Bohr : t -> t
|
||||||
|
val zero : 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 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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user