From de288449f58a54893cf1647faa8b00116303e7bc Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Mon, 22 Apr 2024 13:45:51 +0200 Subject: [PATCH 1/3] Fix dos files in qp_create --- ocaml/Atom.ml | 13 +++++++++---- ocaml/Molecule.ml | 12 +++++++++++- ocaml/Point3d.ml | 4 +++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ocaml/Atom.ml b/ocaml/Atom.ml index d02b20d8..49e788e8 100644 --- a/ocaml/Atom.ml +++ b/ocaml/Atom.ml @@ -22,10 +22,15 @@ let of_string ~units s = } | [ name; x; y; z ] -> let e = Element.of_string name in - { element = e ; - charge = Element.to_charge e; - coord = Point3d.of_string ~units (String.concat " " [x; y; z]) - } + begin + try + { element = e ; + charge = Element.to_charge e; + coord = Point3d.of_string ~units (String.concat " " [x; y; z]) + } + with + | err -> (Printf.eprintf "name = \"%s\"\nxyz = (%s,%s,%s)\n%!" name x y z ; raise err) + end | _ -> raise (AtomError s) diff --git a/ocaml/Molecule.ml b/ocaml/Molecule.ml index 603244c8..3771b6f9 100644 --- a/ocaml/Molecule.ml +++ b/ocaml/Molecule.ml @@ -142,13 +142,21 @@ let of_xyz_string result +let regexp_r = Str.regexp {| |} +let regexp_t = Str.regexp {| |} + let of_xyz_file ?(charge=(Charge.of_int 0)) ?(multiplicity=(Multiplicity.of_int 1)) ?(units=Units.Angstrom) filename = let lines = - match Io_ext.input_lines filename with + Io_ext.input_lines filename + |> List.map (fun s -> Str.global_replace regexp_r "" s) + |> List.map (fun s -> Str.global_replace regexp_t " " s) + in + let lines = + match lines with | natoms :: title :: rest -> let natoms = try @@ -173,6 +181,8 @@ let of_zmt_file ?(units=Units.Angstrom) filename = Io_ext.read_all filename + |> Str.global_replace regexp_r "" + |> Str.global_replace regexp_t " " |> Zmatrix.of_string |> Zmatrix.to_xyz_string |> of_xyz_string ~charge ~multiplicity ~units diff --git a/ocaml/Point3d.ml b/ocaml/Point3d.ml index 57b02bfe..4df375e4 100644 --- a/ocaml/Point3d.ml +++ b/ocaml/Point3d.ml @@ -24,7 +24,9 @@ let of_string ~units s = let l = s |> String_ext.split ~on:' ' |> List.filter (fun x -> x <> "") - |> list_map float_of_string + |> list_map (fun x -> + try float_of_string x with + | Failure msg -> (Printf.eprintf "Bad string: \"%s\"\n%!" x ; failwith msg) ) |> Array.of_list in { x = l.(0) *. f ; From 1c2b737586eba60cfec15ce8c452bdff727c70b9 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 2 May 2024 16:05:13 +0200 Subject: [PATCH 2/3] Fixed Warning with nproc --- src/utils/util.irp.f | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/util.irp.f b/src/utils/util.irp.f index 97cbde67..de01656b 100644 --- a/src/utils/util.irp.f +++ b/src/utils/util.irp.f @@ -327,12 +327,12 @@ subroutine wall_time(t) end BEGIN_PROVIDER [ integer, nproc ] + use omp_lib implicit none BEGIN_DOC ! Number of current OpenMP threads END_DOC - integer, external :: omp_get_num_threads nproc = 1 !$OMP PARALLEL !$OMP MASTER From 425e7e4ee0ac740220bb921ba7a607836b1acffe Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 2 May 2024 16:22:01 +0200 Subject: [PATCH 3/3] Changed symetric_fock_tc into symmetric_fock_tc --- plugins/local/tc_keywords/EZFIO.cfg | 2 +- plugins/local/tc_scf/fock_hermit.irp.f | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/local/tc_keywords/EZFIO.cfg b/plugins/local/tc_keywords/EZFIO.cfg index bc691fc3..e0776136 100644 --- a/plugins/local/tc_keywords/EZFIO.cfg +++ b/plugins/local/tc_keywords/EZFIO.cfg @@ -106,7 +106,7 @@ doc: If |true|, the MO basis is assumed to be bi-orthonormal interface: ezfio,provider,ocaml default: True -[symetric_fock_tc] +[symmetric_fock_tc] type: logical doc: If |true|, using F+F^t as Fock TC interface: ezfio,provider,ocaml diff --git a/plugins/local/tc_scf/fock_hermit.irp.f b/plugins/local/tc_scf/fock_hermit.irp.f index 5a51b324..3460157e 100644 --- a/plugins/local/tc_scf/fock_hermit.irp.f +++ b/plugins/local/tc_scf/fock_hermit.irp.f @@ -4,7 +4,7 @@ BEGIN_PROVIDER [ double precision, good_hermit_tc_fock_mat, (mo_num, mo_num)] BEGIN_DOC -! good_hermit_tc_fock_mat = Hermitian Upper triangular Fock matrix +! good_hermit_tc_fock_mat = Hermitian Upper triangular Fock matrix ! ! The converged eigenvectors of such matrix yield to orthonormal vectors satisfying the left Brillouin theorem END_DOC @@ -14,11 +14,11 @@ BEGIN_PROVIDER [ double precision, good_hermit_tc_fock_mat, (mo_num, mo_num)] good_hermit_tc_fock_mat = Fock_matrix_tc_mo_tot do j = 1, mo_num do i = 1, j-1 - good_hermit_tc_fock_mat(i,j) = Fock_matrix_tc_mo_tot(j,i) + good_hermit_tc_fock_mat(i,j) = Fock_matrix_tc_mo_tot(j,i) enddo enddo -END_PROVIDER +END_PROVIDER BEGIN_PROVIDER [ double precision, hermit_average_tc_fock_mat, (mo_num, mo_num)] @@ -35,7 +35,7 @@ BEGIN_PROVIDER [ double precision, hermit_average_tc_fock_mat, (mo_num, mo_num)] enddo enddo -END_PROVIDER +END_PROVIDER ! --- @@ -44,13 +44,13 @@ BEGIN_PROVIDER [ double precision, grad_hermit] BEGIN_DOC ! square of gradient of the energy END_DOC - if(symetric_fock_tc)then + if(symmetric_fock_tc)then grad_hermit = grad_hermit_average_tc_fock_mat else grad_hermit = grad_good_hermit_tc_fock_mat endif -END_PROVIDER +END_PROVIDER BEGIN_PROVIDER [ double precision, grad_good_hermit_tc_fock_mat] implicit none @@ -64,7 +64,7 @@ BEGIN_PROVIDER [ double precision, grad_good_hermit_tc_fock_mat] grad_good_hermit_tc_fock_mat += dabs(good_hermit_tc_fock_mat(i,j)) enddo enddo -END_PROVIDER +END_PROVIDER ! --- @@ -80,7 +80,7 @@ BEGIN_PROVIDER [ double precision, grad_hermit_average_tc_fock_mat] grad_hermit_average_tc_fock_mat += dabs(hermit_average_tc_fock_mat(i,j)) enddo enddo -END_PROVIDER +END_PROVIDER ! --- @@ -95,8 +95,8 @@ subroutine save_good_hermit_tc_eigvectors() sign = 1 label = "Canonical" output = .False. - - if(symetric_fock_tc)then + + if(symmetric_fock_tc)then call mo_as_eigvectors_of_mo_matrix(hermit_average_tc_fock_mat, mo_num, mo_num, label, sign, output) else call mo_as_eigvectors_of_mo_matrix(good_hermit_tc_fock_mat, mo_num, mo_num, label, sign, output)