47 function qho_prob(alpha, x_current, x_next)
result(Prob)
51 real(real64),
intent(in) :: alpha
52 real(real64),
intent(in) :: x_current, x_next
56 prob = exp(-2*alpha*(x_next*x_next - x_current*x_current))
80 real(real64),
intent(in) :: alpha
81 real(real64),
intent(in) :: x
85 e_loc = alpha + (x*x)*(0.5 - (2*alpha*alpha))
115 real(real64),
dimension(3),
intent(in) :: r_elec, r_nuc
117 real(real64) ::
h1s_wfn, expfac
119 expfac = -norm2(r_elec - r_nuc)
153 real(real64),
dimension(3),
intent(in) :: r_elec, r_nuc
155 real(real64) ::
h2s_wfn, prefac, expfac, r_norm
157 r_norm = norm2(r_elec - r_nuc)
159 expfac = -(r_norm / 2)
194 real(real64),
intent(in) :: c
195 real(real64),
dimension(3),
intent(in) :: r
196 real(real64),
dimension(3),
intent(in) :: r_a, r_b
229 real(real64),
intent(in) :: c
230 real(real64),
dimension(3),
intent(in) :: r_current, r_next
231 real(real64),
dimension(3),
intent(in) :: r_a, r_b
281 real(real64),
intent(in) :: c
282 real(real64),
dimension(3),
intent(in) :: r
283 real(real64),
dimension(3),
intent(in) :: R_a, R_b
285 real(real64),
intent(out) :: E_loc
286 real(real64),
intent(out) :: gradient
288 real(real64),
dimension(2, 3) :: r_diffs
289 real(real64),
dimension(2) :: c_diffs
290 real(real64),
dimension(3) :: r_temp
291 real(real64) :: laplacian
292 real(real64) :: coulomb
293 real(real64) :: c_temp
294 real(real64) :: wfn, wfnx2
304 r_temp(i) = r(i) -
h2plus%ham_fdstep
307 r_temp(i) = r(i) +
h2plus%ham_fdstep
312 laplacian = ((r_diffs(1, 1) - wfnx2 + r_diffs(2, 1)) + &
313 (r_diffs(1, 2) - wfnx2 + r_diffs(2, 2)) + &
314 (r_diffs(1, 3) - wfnx2 + r_diffs(2, 3))) / (
h2plus%ham_fdstep**2)
315 laplacian = laplacian * (-0.5_real64)
317 coulomb = -(1 / norm2(r - r_a))*wfn - (1 / norm2(r - r_b))*wfn
319 e_loc = ((laplacian + coulomb) / wfn) + (1 / norm2(r_a - r_b))
322 if (
h2plus%auto_params)
then
324 c_temp = c -
h2plus%c_fdstep
327 c_temp = c +
h2plus%c_fdstep
330 gradient = (c_diffs(2) - c_diffs(1)) / (2.0_real64 *
h2plus%c_fdstep)
332 gradient = 0.0_real64
358 real(real64),
intent(in) :: c_old
359 real(real64),
intent(in) :: gradient
360 real(real64),
intent(out) :: c_new
362 real(real64) :: damping = 1.0_real64
365 c_new = c_old - (damping * gradient)
398 real(real64),
intent(in) :: s
403 real(real64) :: f_dash
404 real(real64) :: emsoa
414 write(
logid,
"('Starting Newton-Raphson search for parameter a...')")
415 write(
logid, *)
'a abs(f)'
419 f = (1.0_real64 / (1.0_real64 + exp(-s/a))) - a
423 if (abs(f) .lt. tol)
then
425 write(
logid,
"('Value of parameter a converged.')")
433 f = (1.0_real64 / (1.0_real64 + emsoa)) - a
434 f_dash = (-s * emsoa) / ((1.0_real64 + emsoa*emsoa * a*a)) - 1
440 write(
logid,
"(F12.8, ' ', F12.8)") a, abs(f)
446 if (k .ge. maxiter)
then
447 error stop
"Newton-Raphson search for parameter a has failed to converge."
488 function h_2_wfn(a, beta, r_1, r_2, R_a, R_b)
result(wfn)
492 real(real64),
intent(in) :: a
493 real(real64),
intent(in) :: beta
494 real(real64),
dimension(3),
intent(in) :: r_1, r_2
495 real(real64),
dimension(3),
intent(in) :: r_a, r_b
500 real(real64) :: alpha
501 real(real64) :: phi_r1, phi_r2, jastrow
506 phi_r1 = exp(-norm2(r_1 - r_a) / a) + exp(-norm2(r_1 - r_b) / a)
507 phi_r2 = exp(-norm2(r_2 - r_a) / a) + exp(-norm2(r_2 - r_b) / a)
509 jastrow = exp(norm2(r_1 - r_2) / (alpha * (1.0_real64 + beta*norm2(r_1 - r_2))))
511 wfn = phi_r1 * phi_r2 * jastrow
539 function h_2_prob(a, beta, r_1_current, r_2_current, r_1_next, r_2_next, &
540 R_a, R_b)
result(Prob)
544 real(real64),
intent(in) :: a
545 real(real64),
intent(in) :: beta
546 real(real64),
dimension(3),
intent(in) :: r_1_current, r_2_current
547 real(real64),
dimension(3),
intent(in) :: r_1_next, r_2_next
548 real(real64),
dimension(3),
intent(in) :: r_a, r_b
552 prob = (
h_2_wfn(a, beta, r_1_next, r_2_next, r_a, r_b) / &
553 h_2_wfn(a, beta, r_1_current, r_2_current, r_a, r_b))**2
591 subroutine h_2_energy(a, beta, r_1, r_2, R_a, R_b, E_loc, DphiDbeta)
595 real(real64),
intent(in) :: a
596 real(real64),
intent(in) :: beta
597 real(real64),
dimension(3),
intent(in) :: r_1, r_2
598 real(real64),
dimension(3),
intent(in) :: R_a, R_b
600 real(real64),
intent(out) :: E_loc
601 real(real64),
intent(out) :: DphiDbeta
603 real(real64) :: E1, E2, E3, E4, E5, E6, E7, E8
604 real(real64) :: phi_1a, phi_1b, phi_1
605 real(real64) :: phi_2a, phi_2b, phi_2
606 real(real64) :: r_1a, r_1b, r_2a, r_2b, r_12
607 real(real64),
dimension(3) :: r_1a_hat, r_1b_hat, r_2a_hat, r_2b_hat, r_12_hat
609 r_1a = norm2(r_1 - r_a)
610 r_1b = norm2(r_1 - r_b)
611 r_2a = norm2(r_2 - r_a)
612 r_2b = norm2(r_2 - r_b)
613 r_12 = norm2(r_1 - r_2)
615 r_1a_hat = (r_1 - r_a) / spread(r_1a, 1, 3)
616 r_1b_hat = (r_1 - r_b) / spread(r_1b, 1, 3)
617 r_2a_hat = (r_2 - r_a) / spread(r_2a, 1, 3)
618 r_2b_hat = (r_2 - r_b) / spread(r_2b, 1, 3)
619 r_12_hat = (r_1 - r_2) / spread(r_12, 1, 3)
621 phi_1a = exp(-r_1a / a)
622 phi_1b = exp(-r_1b / a)
623 phi_2a = exp(-r_2a / a)
624 phi_2b = exp(-r_2b / a)
626 phi_1 = phi_1a + phi_1b
627 phi_2 = phi_2a + phi_2b
629 e1 = 1.0_real64 / (a*a)
630 e2 = ((phi_1a / r_1a) + (phi_1b / r_1b)) / (a * phi_1)
631 e3 = ((phi_2a / r_2a) + (phi_2b / r_2b)) / (a * phi_2)
632 e4 = (1.0_real64 / r_1a) + (1.0_real64 / r_1b) + (1.0_real64 / r_2a) + (1.0_real64 / r_2b)
633 e5 = 1.0_real64 / r_12
634 e6 = ((((phi_1a * sum(r_1a_hat * r_12_hat, dim=1)) + (phi_1b * sum(r_1b_hat * r_12_hat, dim=1))) / phi_1) &
635 - (((phi_2a * sum(r_2a_hat * r_12_hat, dim=1)) + (phi_2b * sum(r_2b_hat * r_12_hat, dim=1))) / phi_2)) &
636 / (2.0_real64 * a * (1.0_real64 + beta*r_12)**2)
637 e7 = (((4.0_real64*beta + 1.0_real64) * r_12) + 4.0_real64) &
638 / (4.0_real64 * r_12 * (1.0_real64 + beta*r_12)**4)
639 e8 = (1.0_real64 / norm2(r_a - r_b))
641 e_loc = -e1 + e2 + e3 - e4 + e5 + e6 - e7 + e8
643 dphidbeta = -(r_12*r_12) / (2.0_real64*(1.0_real64 + beta*r_12)**2)
668 real(real64),
intent(in) :: beta_old
669 real(real64),
intent(in) :: gradient
670 real(real64),
intent(out) :: beta_new
672 real(real64) :: damping = 1.0_real64
674 beta_new = beta_old - (damping * gradient)
Contains mathematical constants needed throughout the code, all of which are globally accessible.
real(real64), parameter pi_dash_2
1 / (4*sqrt(2*pi)) - multiplication factor used by H2s_wfn
real(real64), parameter pi_dash
1 / sqrt(pi) - multiplication factor used by H1s_wfn
Contains derived types, and global variables to store input values of simulation parameters.
type(h2plus_type) h2plus
To store inputs for H2 ion system.
logical i_log
Indicates whether the processor needs to write the logfile.
integer logid
To store logfile unit.
Contains local energy and transition probability solvers for available problems.
real(real64) function h_2_cusp(s)
Calculates a value for a given the bond length s by Newton-Raphson iteration.
subroutine h_2_update_beta(beta_old, gradient, beta_new)
Updates the parameter in the problem by dampened steepest descent.
real(real64) function qho_energy(alpha, x)
Calculates local energy for quantum harmonic oscillator problem.
real(real64) function h_2_plus_prob(c, r_current, r_next, R_a, R_b)
Calculates transition probability for the problem.
real(real64) function h_2_plus_wfn(c, r, R_a, R_b)
Calculates trial wavefunction for the problem.
real(real64) function qho_prob(alpha, x_current, x_next)
Calculates transition probability for quantum harmonic oscillator problem.
real(real64) function h1s_wfn(r_elec, R_nuc)
Calculates value of the wavefunction of a hydrogen 1s orbital.
real(real64) function h2s_wfn(r_elec, R_nuc)
[DEPRECATED] Calculates value of the wavefunction of a hydrogen 2s orbital.
subroutine h_2_energy(a, beta, r_1, r_2, R_a, R_b, E_loc, DphiDbeta)
{UPDATE ME} Calculates local energy for the problem.
subroutine h_2_plus_energy(c, r, R_a, R_b, E_loc, gradient)
Calculates local energy for the problem.
real(real64) function h_2_prob(a, beta, r_1_current, r_2_current, r_1_next, r_2_next, R_a, R_b)
Calculates transition probability for the problem.
real(real64) function h_2_wfn(a, beta, r_1, r_2, R_a, R_b)
Calculates trial wavefunction for the problem.
subroutine h_2_plus_update_c(c_old, gradient, c_new)
Updates the parameter in the problem by dampened steepest descent.