diff --git a/ocaml/.gitignore b/ocaml/.gitignore index 5618a6c0..f27fa0c8 100644 --- a/ocaml/.gitignore +++ b/ocaml/.gitignore @@ -16,6 +16,8 @@ qp_edit qp_edit.ml qp_edit.native qp_print +qp_print_basis +qp_print_basis.native qp_print.native qp_run qp_run.native diff --git a/ocaml/qp_create_ezfio_from_xyz.ml b/ocaml/qp_create_ezfio_from_xyz.ml index ee7e7d40..d625c15a 100644 --- a/ocaml/qp_create_ezfio_from_xyz.ml +++ b/ocaml/qp_create_ezfio_from_xyz.ml @@ -133,10 +133,6 @@ let run ?o b c d m p xyz_file = let fetch_channel basis = let command = - if (p) then - Qpackage.root ^ "/scripts/get_basis.sh \"" ^ temp_filename - ^ "." ^ basis ^ "\" \"" ^ basis ^"\" pseudo" - else Qpackage.root ^ "/scripts/get_basis.sh \"" ^ temp_filename ^ "." ^ basis ^ "\" \"" ^ basis ^"\"" in @@ -344,7 +340,7 @@ let run ?o b c d m p xyz_file = (* Doesn't work... *) if (p) then begin - Qpackage.root ^ "/scripts/pseudo/put_pseudo_in_ezfio.py " ^ ezfio_file + Qpackage.root ^ "/scripts/pseudo/put_pseudo_in_ezfio.py " ^ ezfio_file ^ " " ^ " BFD-Pseudo" |> Sys.command_exn end; diff --git a/ocaml/qp_print_basis.ml b/ocaml/qp_print_basis.ml index 6b8f49a5..679cd42b 100644 --- a/ocaml/qp_print_basis.ml +++ b/ocaml/qp_print_basis.ml @@ -1,7 +1,7 @@ open Core.Std open Qptypes -let () = +let basis ()= let ezfio_filename = Sys.argv.(1) in @@ -16,4 +16,24 @@ let () = Input.Ao_basis.to_rst basis |> Rst_string.to_string |> print_endline + ;; +let mo ()= + let ezfio_filename = + Sys.argv.(1) + in + if (not (Sys.file_exists_exn ezfio_filename)) then + failwith "Error reading EZFIO file"; + Ezfio.set_file ezfio_filename; + let mo_coef = + match Input.Mo_basis.read () with + | Some mo_coef -> mo_coef + | _ -> failwith "Error reading the mo set" + in + Input.Mo_basis.to_rst mo_coef + |> Rst_string.to_string + |> print_endline + ;; + +basis ();; +mo ();; \ No newline at end of file diff --git a/scripts/get_basis.sh b/scripts/get_basis.sh index c708511b..22d506c6 100755 --- a/scripts/get_basis.sh +++ b/scripts/get_basis.sh @@ -46,15 +46,4 @@ then exit 1 fi -pseudo="$1" -shift - -if [[ -z $pseudo ]] -then - ${EMSL_API_ROOT}/EMSL_api.py get_basis_data --treat_l --save --path="${tmpfile}" --basis="${basis}" -else - ${EMSL_API_ROOT}/EMSL_api.py get_basis_data --save --path="${tmpfile}" --basis="${basis}" --db_path="${EMSL_API_ROOT}/db/Pseudo.db" -# echo ${EMSL_API_ROOT}/EMSL_api.py get_basis_data --save --path="${tmpfile}" --basis="${basis}" --db_path="${EMSL_API_ROOT}/db/Pseudo.db" 1>&2 -# echo $PWD/BASIS -fi - +${EMSL_API_ROOT}/EMSL_api.py get_basis_data --treat_l --save --path="${tmpfile}" --basis="${basis}" diff --git a/scripts/pseudo/put_pseudo_in_ezfio.py b/scripts/pseudo/put_pseudo_in_ezfio.py index 6ad69f10..bfe1d761 100755 --- a/scripts/pseudo/put_pseudo_in_ezfio.py +++ b/scripts/pseudo/put_pseudo_in_ezfio.py @@ -4,7 +4,7 @@ Create the pseudo potential for a given atom Usage: - put_pseudo_in_ezfio.py + put_pseudo_in_ezfio.py [] Help: atom is the Abreviation of the atom @@ -28,7 +28,7 @@ import re p = re.compile(ur'\|(\d+)><\d+\|') -def get_pseudo_str(l_atom): +def get_pseudo_str(db_path,pseudo_name,l_atom): """ Run EMSL_local for getting the str of the pseudo potential @@ -53,7 +53,6 @@ def get_pseudo_str(l_atom): EMSL_root = "{0}/install/emsl/".format(qpackage_root) EMSL_path = "{0}/EMSL_api.py".format(EMSL_root) - db_path = "{0}/db/Pseudo.db".format(EMSL_root) str_ = "" @@ -64,7 +63,7 @@ def get_pseudo_str(l_atom): l_cmd_head = [EMSL_path, "get_basis_data", "--db_path", db_path, - "--basis", "BFD-Pseudo"] + "--basis", pseudo_name] process = Popen(l_cmd_head + l_cmd_atom, stdout=PIPE, stderr=PIPE) @@ -180,19 +179,22 @@ def get_zeff_alpha_beta(str_ele): # from elts_num_ele import name_to_elec + from math import ceil, floor z = name_to_elec[name] z_eff = z - z_remove - alpha = (z_remove / 2) - beta = (z_remove / 2) + alpha = int(ceil(z_remove / 2.)) + beta = int(floor(z_remove / 2.)) + + # Remove more alpha, than beta # _ # |_) _ _|_ ._ ._ # | \ (/_ |_ |_| | | | # - return [z_eff, alpha, beta] + return [z_remove, z_eff, alpha, beta] def add_zero(array, size, type): @@ -224,6 +226,12 @@ def make_it_square(matrix, dim, type=float): return matrix +def full_path(path): + path = os.path.expanduser(path) + path = os.path.expandvars(path) + path = os.path.abspath(path) + return path + if __name__ == "__main__": arguments = docopt(__doc__) # ___ @@ -235,19 +243,22 @@ if __name__ == "__main__": # E Z F I O # # ~#~#~#~#~ # - ezfio_path = arguments[""] - ezfio_path = os.path.expanduser(ezfio_path) - ezfio_path = os.path.expandvars(ezfio_path) - ezfio_path = os.path.abspath(ezfio_path) - + ezfio_path = full_path(arguments[""]) ezfio.set_file("{0}".format(ezfio_path)) # ~#~#~#~#~#~#~#~#~#~#~ # # P s e u d o _ d a t a # # ~#~#~#~#~#~#~#~#~#~#~ # + if arguments[""]: + db_path = full_path(arguments[""]) + else: + db_path= full_path("{0}/data/BFD-Pseudo.db".format(qpackage_root)) + + pseudo_name = arguments[""] l_ele = ezfio.get_nuclei_nucl_label() - str_ = get_pseudo_str(l_ele) + + str_ = get_pseudo_str(db_path,pseudo_name,l_ele) # _ # |_) _. ._ _ _ @@ -257,7 +268,7 @@ if __name__ == "__main__": l_str_ele = [str_ele for str_ele in str_.split("Element Symbol: ") if str_ele] - for i in "l_zeff v_k n_k dz_k v_kl n_kl dz_kl".split(): + for i in "l_zeff l_remove v_k n_k dz_k v_kl n_kl dz_kl".split(): exec("{0} = []".format(i)) alpha_tot = 0 @@ -296,11 +307,13 @@ if __name__ == "__main__": # Z _ e f f , a l p h a / b e t a _ e l e c # # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # - zeff, alpha, beta = get_zeff_alpha_beta(str_ele) + zremove, zeff, alpha, beta = get_zeff_alpha_beta(str_ele) alpha_tot += alpha beta_tot += beta l_zeff.append(zeff) + l_remove.append(zremove) + # _ # /\ _| _| _|_ _ _ _ _|_ o _ # /--\ (_| (_| |_ (_) (/_ /_ | | (_) @@ -311,6 +324,7 @@ if __name__ == "__main__": # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # ezfio.nuclei_nucl_charge = l_zeff + ezfio.pseudo_nucl_charge_remove = l_remove alpha_tot = ezfio.get_electrons_elec_alpha_num() - alpha_tot beta_tot = ezfio.get_electrons_elec_beta_num() - beta_tot diff --git a/src/Pseudo/EZFIO.cfg b/src/Pseudo/EZFIO.cfg index 58df78a0..fc23b678 100644 --- a/src/Pseudo/EZFIO.cfg +++ b/src/Pseudo/EZFIO.cfg @@ -1,3 +1,10 @@ +[nucl_charge_remove] +doc: Nuclear charges removed +type:double precision +size: (nuclei.nucl_num) +interface: ezfio, provider + + [pseudo_klocmax] doc: test type:integer diff --git a/test/bats/qp.bats b/test/bats/qp.bats index f1c2e341..fcfe8edb 100644 --- a/test/bats/qp.bats +++ b/test/bats/qp.bats @@ -7,6 +7,9 @@ # So we strip the "-", is the abs value of the poor function eq() { awk -v n1=${1#-} -v n2=${2#-} -v p=$3 'BEGIN{ if ((n1-n2)^2 < p^2) exit 0; exit 1}' + if [ $? -ne 0 ]; then + echo $1 $2 + fi } #: "${QP_ROOT?Pls set your quantum_package.rc}" @@ -44,8 +47,10 @@ cd ${TEST_DIR} qp_run full_ci HBO.ezfio energy="$(ezfio get full_ci energy)" eq $energy -98.9649618899175 1E-2 + # -98.964541775171284 energy_pt2="$(ezfio get full_ci energy_pt2)" eq $energy_pt2 -98.966228232164 1E-5 + #  -98.966209348290292 } @test "cas_sd_selected HBO STO-3G" { @@ -58,6 +63,7 @@ cd ${TEST_DIR} # Check energy energy="$(ezfio get cas_sd energy)" eq $energy -98.9646946027433 1E-5 + #  -98.964352450115271 } @test "mrcc_cassd HBO STO-3G" { @@ -69,6 +75,7 @@ cd ${TEST_DIR} # Check energy energy="$(ezfio get mrcc_cassd energy)" eq $energy -98.9653606184686 1E-5 + # -98.96509060765523 } @test "script conversion HBO.out" {