mirror of
https://gitlab.com/scemama/QCaml.git
synced 2024-12-22 04:13:33 +01:00
Pretty printing
This commit is contained in:
parent
72eb1ce5c3
commit
e3e16bd5bd
@ -1,5 +1,6 @@
|
||||
type t
|
||||
|
||||
(** Returns an array of the basis set per atom *)
|
||||
let of_nuclei_and_general_basis n b =
|
||||
Array.map (fun (e, center) ->
|
||||
List.assoc e b
|
||||
@ -14,7 +15,25 @@ let of_nuclei_and_general_basis n b =
|
||||
|
||||
|
||||
let to_string b =
|
||||
Array.map (fun i -> Contracted_shell.to_string i) b
|
||||
|> Array.to_list
|
||||
|> String.concat "\n"
|
||||
let line ="
|
||||
-----------------------------------------------------------------------
|
||||
" in
|
||||
"
|
||||
Atomic Basis set
|
||||
----------------
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
Angular Coordinates (Bohr) Exponents Coefficients
|
||||
Momentum X Y Z
|
||||
-----------------------------------------------------------------------
|
||||
"
|
||||
^( Array.mapi (fun atom_id basis ->
|
||||
Array.map (fun i ->
|
||||
Contracted_shell.to_string i) basis
|
||||
|> Array.to_list
|
||||
|> String.concat line
|
||||
) b
|
||||
|> Array.to_list
|
||||
|> String.concat line)
|
||||
^ line
|
||||
|
||||
|
@ -18,12 +18,14 @@ let norm_coef a i = a.norm_coef.(i)
|
||||
|
||||
|
||||
let to_string s =
|
||||
let coord =
|
||||
Coordinate.to_Bohr s.center
|
||||
in
|
||||
let open Printf in
|
||||
[ sprintf "center: %s" (Coordinate.to_string s.center) ;
|
||||
sprintf "angular momentum: %s" (Angular_momentum.to_string s.totAngMom) ]
|
||||
@ (Array.map2 (fun e c -> sprintf "expo: %e coeff: %e" e c) s.expo s.coef
|
||||
|> Array.to_list) @ ["\n"]
|
||||
|> String.concat "\n"
|
||||
( sprintf "%2s %10.6f %10.6f %10.6f " (Angular_momentum.to_string s.totAngMom)
|
||||
(Coordinate.x coord) (Coordinate.y coord) (Coordinate.z coord) ) ^
|
||||
(Array.map2 (fun e c -> sprintf "%16.8e %16.8e" e c) s.expo s.coef
|
||||
|> Array.to_list |> String.concat (sprintf "\n%36s" " ") )
|
||||
|
||||
(** Normalization coefficient of contracted function i, which depends on the
|
||||
exponent and the angular momentum. Two conventions can be chosen : a single
|
||||
|
@ -23,3 +23,29 @@ let of_zmt_file ~filename =
|
||||
|> Zmatrix.to_xyz
|
||||
|> Array.map (fun (e,x,y,z) -> (e, Coordinate.of_3_floats x y z ))
|
||||
|
||||
let to_string atoms =
|
||||
"
|
||||
Nuclear Coordinates (Angstrom)
|
||||
------------------------------
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
Center Atomic Element Coordinates (Angstroms)
|
||||
Number X Y Z
|
||||
-----------------------------------------------------------------------
|
||||
" ^
|
||||
(Array.mapi (fun i (e, coord) ->
|
||||
let coord =
|
||||
Coordinate.to_Angstrom coord
|
||||
in
|
||||
Printf.sprintf " %5d %5d %5s %12.6f %12.6f %12.6f"
|
||||
(i+1) (Element.to_int e) (Element.to_string e)
|
||||
(Coordinate.x coord) (Coordinate.y coord) (Coordinate.z coord)
|
||||
) atoms
|
||||
|> Array.to_list
|
||||
|> String.concat "\n" ) ^
|
||||
"
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
"
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ let white = [' ' '\t']+
|
||||
let word = [^' ' '\t' '\n']+
|
||||
let letter = ['A'-'Z' 'a'-'z']
|
||||
let integer = ['0'-'9']+
|
||||
let real = '-'? integer '.' integer (['e' 'E'] ('+'|'-')? integer)?
|
||||
let real = '-'? (integer '.' integer | integer '.' | '.' integer) (['e' 'E'] ('+'|'-')? integer)?
|
||||
|
||||
|
||||
rule read_all = parse
|
||||
@ -20,8 +20,9 @@ rule read_all = parse
|
||||
|
||||
|
||||
{
|
||||
let debug () =
|
||||
let ic = open_in "caffeine.xyz" in
|
||||
(* DEBUG
|
||||
let () =
|
||||
let ic = open_in "h2o.xyz" in
|
||||
let lexbuf = Lexing.from_channel ic in
|
||||
while true do
|
||||
let s =
|
||||
@ -35,4 +36,5 @@ rule read_all = parse
|
||||
in
|
||||
print_endline s
|
||||
done;
|
||||
*)
|
||||
}
|
||||
|
@ -34,14 +34,14 @@ title:
|
||||
| title_list EOL { $1 }
|
||||
|
||||
text:
|
||||
| WORD {$1 }
|
||||
| SPACE {$1 }
|
||||
| FLOAT {(string_of_float $1)}
|
||||
| INTEGER {(string_of_int $1)}
|
||||
| WORD { $1 }
|
||||
| SPACE { $1 }
|
||||
| FLOAT { (string_of_float $1)}
|
||||
| INTEGER { (string_of_int $1)}
|
||||
|
||||
title_list:
|
||||
| { "" }
|
||||
| title_list text { $1 ^ $2 }
|
||||
| title_list text { ($1 ^ $2) }
|
||||
|
||||
atoms_xyz:
|
||||
| atoms_list EOL { List.rev $1 }
|
||||
|
@ -12,5 +12,7 @@ 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
|
||||
|
||||
|
@ -24,11 +24,13 @@ let run ~coord ~basis =
|
||||
and general_basis =
|
||||
Gamess_reader.read ~filename:basis_file
|
||||
in
|
||||
print_endline @@ Nuclei.to_string nuclei;
|
||||
|
||||
let basis =
|
||||
Basis.of_nuclei_and_general_basis nuclei general_basis
|
||||
in
|
||||
Array.map Basis.to_string basis
|
||||
|> Array.iter print_endline
|
||||
Basis.to_string basis
|
||||
|> print_endline
|
||||
|
||||
|
||||
let () =
|
||||
|
Loading…
Reference in New Issue
Block a user