2018-01-19 03:14:06 +01:00
|
|
|
type t = (Element.t * Coordinate.t) array
|
2018-01-17 15:56:57 +01:00
|
|
|
|
|
|
|
let of_xyz_file ~filename =
|
|
|
|
let lexbuf =
|
|
|
|
let ic = open_in filename in
|
|
|
|
Lexing.from_channel ic
|
|
|
|
in
|
|
|
|
Xyz_parser.input Nuclei_lexer.read_all lexbuf
|
|
|
|
|
|
|
|
|
|
|
|
let of_zmt_file ~filename =
|
|
|
|
let ic = open_in filename in
|
|
|
|
let rec aux accu =
|
|
|
|
try
|
|
|
|
let line = input_line ic in
|
|
|
|
aux (line::accu)
|
|
|
|
with End_of_file ->
|
|
|
|
close_in ic;
|
|
|
|
List.rev accu
|
|
|
|
|> String.concat "\n"
|
|
|
|
in aux []
|
|
|
|
|> Zmatrix.of_string
|
|
|
|
|> Zmatrix.to_xyz
|
2018-01-18 00:21:05 +01:00
|
|
|
|> Array.map (fun (e,x,y,z) -> (e, Coordinate.of_3_floats x y z ))
|
2018-01-17 15:56:57 +01:00
|
|
|
|
2018-01-18 17:39:10 +01:00
|
|
|
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" ) ^
|
|
|
|
"
|
|
|
|
-----------------------------------------------------------------------
|
|
|
|
|
|
|
|
"
|
|
|
|
|
|
|
|
|