@@ -0,0 +1,2222 @@
+#!/usr/bin/env python3%0A%0A%22%22%22%0AHarmonic oscillator PIGS example.%0A%0AAn oscillator with an angular frequency of x kelvin has a ground state%0Apotential energy of x/4 kelvin and a total energy of x/2 kelvin. One with a%0Amass of 1 electron mass and angular frequency of 1 K has a spread of about 120%0Anm in either direction from the origin; one with a mass of 10 electron masses%0Aspreads about 40 nm. The following are some possible combinations of arguments%0Ato try:%0A%0A  --mass 1 --omega 1 --grid-range 120 --grid-len 100 --beta 12 --num-links 1200%0A%0A  --mass 10 --omega 1 --grid-range 40 --grid-len 100 --beta 12 --num-links 1200%0A%22%22%22%0A%0Afrom argparse import ArgumentParser%0A%0Afrom pathintmatmult.constants import HBAR, KB, ME%0Afrom pathintmatmult.nmm import PIGSMM%0Afrom pathintmatmult.potentials import harmonic_potential%0A%0A%0A# Parse arguments.%0Ap = ArgumentParser(description='Calculate HO ground state properties using PIGSMM.')%0Ap_config = p.add_argument_group('configuration')%0A%0Ap_config.add_argument('--mass', metavar='M', type=float, required=True, help='particle mass (electron masses)')%0Ap_config.add_argument('--omega', metavar='W', type=float, required=True, help='angular frequency (K)')%0Ap_config.add_argument('--grid-range', metavar='R', type=float, required=True, help='grid range from origin (nm)')%0Ap_config.add_argument('--grid-len', metavar='L', type=int, required=True, help='number of points on grid')%0Ap_config.add_argument('--beta', metavar='B', type=float, required=True, help='propagation length (1/K)')%0Ap_config.add_argument('--num-links', metavar='P', type=int, required=True, help='number of links')%0A%0Aargs = p.parse_args()%0A%0Amass = args.mass * ME # g/mol%0Aomega = args.omega * KB / HBAR # 1/ps%0Agrid_range = args.grid_range # nm%0Agrid_len = args.grid_len # 1%0Abeta = args.beta / KB # mol/kJ%0Anum_links = args.num_links # 1%0A%0A%0A# Calculate values.%0Aharmonic = harmonic_potential(m=mass, w=omega)%0Aho_pigs = PIGSMM(mass, grid_range, grid_len, beta, num_links, harmonic)%0A%0Aestimated_potential_energy = ho_pigs.expectation_value(harmonic) / KB # K%0A%0Aprint('V = %7B%7D K'.format(estimated_potential_energy))%0A# According to the virial theorem, %3CK%3E = %3CV%3E for a harmonic oscillator.%0Aprint('E_virial = %7B%7D K'.format(2 * estimated_potential_energy))%0A

Add harmonic oscillator example