Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE_NOTES.org
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- Using now standard convention in RDM
- Added molecular properties
- Added GTOs with complex exponent
- Added domain perturbation theory (module ~domain_perturbation~)

*** TODO: take from dev
- Updated version of f77-zmq
Expand Down
102 changes: 102 additions & 0 deletions src/domain_perturbation/50.domain_perturbation.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/usr/bin/env bats

source $QP_ROOT/tests/bats/common.bats.sh
source $QP_ROOT/quantum_package.rc

# Deterministic evaluation, compared to reference values
# The tests need converged orbitals: the SCF is run first. The
# perturbative energies depend on the orbitals (not only on the HF energy),
# for example on the rotations of degenerate orbitals, hence the tolerances.
function scf() {
test_exe scf || skip
qp set_file $1
qp reset --mos
qp set scf_utils n_it_scf_max 50
qp run scf
}

function run() {
thresh=1.e-5
test_exe domain_pert || skip
qp edit --check
qp set domain_perturbation domain_chebyshev false
qp set domain_perturbation n_pert $2
qp set domain_perturbation n_det_domain $3
qp set domain_perturbation n_walkers 0
qp run domain_pert
energies="$(ezfio get domain_perturbation domain_energy | tr '[],' ' ')"
i=1
for e in $1 ; do
energy="$(echo $energies | cut -d ' ' -f $i)"
eq $energy $e $thresh
i=$((i+1))
done
}

# Chebyshev series, compared to the full CI energies
function run_cheb() {
thresh=1.e-5
test_exe domain_pert || skip
qp edit --check
qp set domain_perturbation domain_chebyshev true
qp set domain_perturbation domain_cheb_auto true
qp set domain_perturbation n_pert 10
qp set domain_perturbation n_det_domain 1
qp set domain_perturbation n_walkers 0
qp run domain_pert
qp set domain_perturbation domain_chebyshev false
energies="$(ezfio get domain_perturbation domain_energy | tr '[],' ' ')"
i=1
for e in $1 ; do
energy="$(echo $energies | cut -d ' ' -f $i)"
eq $energy $e $thresh
i=$((i+1))
done
}

# Stochastic evaluation, compared to the exact one
function run_stoch() {
test_exe domain_pert || skip
qp set domain_perturbation domain_chebyshev false
qp set domain_perturbation n_pert $1
qp set domain_perturbation n_det_domain $2
qp set domain_perturbation exact_coupling $3
qp set domain_perturbation domain_heat_bath $5
qp set domain_perturbation n_walkers 5000
qp set domain_perturbation n_replicas 20
qp set domain_perturbation domain_seed 1
qp run domain_pert
energy="$(ezfio get domain_perturbation domain_energy \
| tr -d '[] ' | cut -d ',' -f 1)"
error="$(ezfio get domain_perturbation domain_energy_error \
| tr -d '[] ' | cut -d ',' -f 1)"
eq "$energy" "$4" "$(LC_ALL=C awk -v e="$error" 'BEGIN { print 6*e }')"
}

@test "H3_2 HF" {
scf h3_2.ezfio
qp reset -d
run "-1.610273153311" 4 1
run "-1.609959380386" 4 4
}

@test "H3_2 CIS 3 states" {
scf h3_2.ezfio
qp reset -d
qp set determinants n_states 3
qp run cis
run "-1.610008725602 -1.311815765541 -1.206677373119" 5 1
run "-1.610022696198 -1.311852657934 -1.206705811156" 5 6
run_cheb "-1.610031316672 -1.311908009016"
qp set determinants n_states 1
}

@test "H4_1 HF" {
scf h4_1.ezfio
qp reset -d
run "-2.017046423901" 4 1
run "-2.016898059074" 4 4
run_stoch 4 4 true "-2.016898059074" false
run_stoch 4 4 true "-2.016898059074" true
run_stoch 4 1 false "-2.017046423901" true
}
83 changes: 83 additions & 0 deletions src/domain_perturbation/EZFIO.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
[n_pert]
type: Strictly_positive_int
doc: Maximum order of the domain perturbation theory. Orders 2 to n_pert are computed.
interface: ezfio,provider,ocaml
default: 3

[n_det_domain]
type: Strictly_positive_int
doc: Maximum number of determinants in the domain of an external determinant. If 1, the domains are singletons and the second order is the Epstein-Nesbet |PT2|.
interface: ezfio,provider,ocaml
default: 1

[n_walkers]
type: Positive_int
doc: Average number of walkers per generation. If 0, all the sums are done deterministically (small systems only).
interface: ezfio,provider,ocaml
default: 1000000

[n_replicas]
type: Strictly_positive_int
doc: Number of independent stochastic replicas.
interface: ezfio,provider,ocaml
default: 20

[exact_coupling]
type: logical
doc: If |true|, the coupling vector between the reference state and the external determinants is stored exactly, and the second order is exact. If |false|, this vector is sampled, and its elements needed by the scores are computed on the fly.
interface: ezfio,provider,ocaml
default: True

[domain_seed]
type: Positive_int
doc: Seed of the random number generator
interface: ezfio,provider,ocaml
default: 1

[domain_energy]
type: double precision
doc: Total energy up to order n_pert
interface: ezfio
size: (determinants.n_states)

[domain_energy_error]
type: double precision
doc: Statistical error on the total energy up to order n_pert
interface: ezfio
size: (determinants.n_states)

[domain_chebyshev]
type: logical
doc: If |true|, the series is evaluated at the energy E_0 + E_2 of each state and accelerated with Chebyshev polynomials, and the energy is obtained self-consistently. If |false|, the Rayleigh-Schrodinger series is computed.
interface: ezfio,provider,ocaml
default: False

[domain_cheb_auto]
type: logical
doc: If |true|, the interval of the Chebyshev polynomials is estimated from the terms of the series when at least 4 of them are available. If |false|, or if the estimation fails, domain_cheb_min and domain_cheb_max are used.
interface: ezfio,provider,ocaml
default: True

[domain_cheb_min]
type: double precision
doc: Lower bound of the spectrum of the propagator
interface: ezfio,provider,ocaml
default: -1.

[domain_cheb_max]
type: double precision
doc: Upper bound of the spectrum of the propagator, less than 1
interface: ezfio,provider,ocaml
default: 0.6

[domain_heat_bath]
type: logical
doc: If |true|, the excitations are drawn with the heat-bath algorithm, which does not enumerate the connected determinants. If |false|, all the connected determinants are enumerated (small systems).
interface: ezfio,provider,ocaml
default: True

[domain_minres_tol]
type: double precision
doc: Relative convergence threshold of the minimal residual method that applies the reduced resolvent of the reference space. The resulting error on the energies is much smaller than the statistical error for the default value.
interface: ezfio,provider,ocaml
default: 1.e-8
5 changes: 5 additions & 0 deletions src/domain_perturbation/NEED
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
davidson_undressed
determinants
bitmask
mo_two_e_ints
hamiltonian
Loading
Loading