def poptraj(T1): dyn = initdyn() geo = initgeom() ph = physconst() pec, der = abinitio.inp_out(0, 0, geo, T1) # First ab-initio run T1.setpotential_traj(pec) # taking V(R) from ab-initio T1.setderivs_traj( der ) # derivatives matrix mass-weighted (possibly change that), diagonals are forces and off-d are nacmes T1.setmass_traj( geo.masses ) # mass of every atom in a.u (the dimmension is natoms/nparts) T1.setmassall_traj( geo.massrk ) # mass in every degree of freedom (careful to use it, it can triple the division/multiplication easily) amps = np.zeros(T1.nstates, dtype=np.complex128) amps[ dyn.inipes - 1] = 1.00 # Amplitudes of Ehrenfest trajectories, they should be defined as a=d *exp(im*S) T1.setamplitudes_traj(amps) phases = np.zeros( T1.nstates) # Phase of the wfn, would be S in the previous equation T1.setphases_traj(phases) T1.setwidth_traj(dyn.gamma) return T1
def __init__(self): ph = physconst() # Call to a dict of physical constants self.natoms, self.atnames, self.rk, self.comments = process_geometry( ) # Process xyz file and output required parameters massesdict = get_atomic_masses() # Mass of each atom mass = np.zeros((self.natoms)) for i in range(0, self.natoms): mass[i] = massesdict[self.atnames[i]] * 1822.887 self.masses = np.double(mass) self.rkangs = np.double( self.rk) # List of initial atomic xyz coords, 3*N dim # self.rk = CofMass(self.rk, self.masses, self.natoms) # Set the geometry in the center of mass count = 0 rkbohr_mass = np.zeros( (self.natoms * 3)) # Convert the coordinates to massweighted au masses_rk = np.zeros((self.natoms * 3)) for i in range(0, self.natoms): for j in range(0, 3): rkbohr_mass[count] = self.rk[count] / ph.bohr * np.sqrt( self.masses[i]) masses_rk[count] = self.masses[i] count = count + 1 self._rkinit = self.rk / ph.bohr self.ndf = self.natoms * 3 self.massrk = masses_rk
def __init__(self): ph = physconst() self._ntraj = 50 # Number of trajectories self._gamma = np.asarray([22.7, 22.7, 4.7, 4.7, 4.7, 4.7]) # Gamma var, width of the gaussians self._nstep = 100 # Time-steps by trajectory self._dt = (0.1 * 1e-15 / (ph.au2sec)) self._nstates = 2 self._state = range(0, self._nstates) # array of states self._inipes = 2 # Initial state self._e_ref = np.double( -77.67785291) #Reference energy for the ground state
def __init__(self): ''' Use the data for H2 system''' ph = physconst() self.natoms = 1 self.atnum = 1 masses_dict = get_atomic_masses() self.massH = mass2au(masses_dict['H']) self.mass = self.massH / 2 self.K = 0.35 self.rkinit = np.zeros(3) self.ndf = 3
def inittraj(): dyn = initdyn() geo = initgeom() ph = physconst() '''First initialize and populate one trajectory''' T1 = initialize_traj.trajectory(geo.natoms, 3, dyn.nstates) # qin, pin = Wigner_dist.WignerSampling() q = np.zeros(geo.ndf) p = np.zeros_like(q) with open('initialqp.dat', 'r') as f: f.readline() for i in range(geo.ndf): N, M = f.readline().strip().split() q[i] = np.double(float(N.replace('D', 'E'))) / np.sqrt( geo.massrk[i]) p[i] = np.double(float(M.replace('D', 'E'))) * np.sqrt( geo.massrk[i]) T1.setposition_traj(q + geo.rkinit) T1.setmomentum_traj(p) pec, der = abinitio.inp_out(0, 0, geo, T1) # First ab-initio run print(pec) T1.setpotential_traj(pec) # taking V(R) from ab-initio T1.setderivs_traj( der ) # derivatives matrix mass-weighted (possibly change that), diagonals are forces and off-d are nacmes T1.setmass_traj( geo.masses ) # mass of every atom in a.u (the dimmension is natoms/nparts) T1.setmassall_traj( geo.massrk ) # mass in every degree of freedom (careful to use it, it can triple the division/multiplication easily) amps = np.zeros(T1.nstates, dtype=np.complex128) amps[ dyn.inipes - 1] = 1.00 # Amplitudes of Ehrenfest trajectories, they should be defined as a=d *exp(im*S) T1.setamplitudes_traj(amps) phases = np.zeros( T1.nstates) # Phase of the wfn, would be S in the previous equation T1.setphases_traj(phases) T1.setwidth_traj(dyn._gamma) return T1
def transform_q_to_r(q, geo, first): first = False ph = physconst() k = 0 r = np.zeros((3, geo.natoms)) diff = np.double(q) for i in range(geo.natoms): for j in range(3): if first: mass_inv = 1.0 / np.sqrt(geo.masses[i]) else: mass_inv = 1.0 r[j, i] = mass_inv * (diff[k]) * ph.bohr k += 1 return r # vector->matrix, if first mass weights
def create_input(trajN, istep, q, geo): ab = ab_par() ph = physconst() dyn = initdyn() if trajN == 0 and istep == 0: first = True else: first = False # Molpro input, it must be changed for other codes '''routine to create molpro input, valid for molpro2012''' file = 'molpro_traj_' + str(trajN) + '_' + str(istep) + '.inp' file2 = 'molpro_traj_' + str(trajN) + '_' + str(istep) + '.mld' # if first: r = transform_q_to_r(q, geo, first) # if istep==0 and trajN==0: # r=np.transpose(np.asarray([[7.0544201503E-01,-8.8768894715E-03,-6.6808940143E-03],[-6.8165975936E-01,1.7948934206E-02,4.0230273972E-03],[ 1.2640943417E+00,9.0767471618E-01,-3.0960211126E-02],[-1.4483835697E+00 ,8.7539956319E-01 ,4.6789959947E-02],[1.0430033100E+00,-9.0677165411E-01 ,8.1418967247E-02],[-1.1419988770E+00,-9.8436525752E-01,-6.5589218426E-02]])) with open(file, 'w') as f: f.write( '***,' + ab.molecule + ' ' + 'calculation of ' + str(istep) + ' step in trejectory ' + str(trajN) + '\n') line_wr_2 = 'file,2,' + str(trajN) + '.check.wfu,new\n' # f.write(line_wr_2) if first: line_wr = 'file,3,003.molpro.wfu,new\n' else: line_wr = 'file,3,003.molpro.wfu\n' f.write(line_wr) f.write('memory,100,m\n') f.write('''gprint,orbitals,civector,angles=-1,distance=-1 gthresh,twoint=1.0d-13 gthresh,energy=1.0d-7,gradient=1.0d-2 gthresh,thrpun=0.001\n''') f.write('punch,molpro.pun,new\n') f.write('basis=6-31g**\n') # f.write('basis={\n') # f.write(''' ! # ! HYDROGEN (4s,1p) -> [2s,1p] # s, H , 13.0100000, 1.9620000, 0.4446000 # c, 1.3, 0.0196850, 0.1379770, 0.4781480 # s, H , 0.1220000 # c, 1.1, 1.0000000 # p, H , 0.7270000 # c, 1.1, 1.0000000 # ! # ! # ! CARBON (9s,4p,1d) -> [3s,2p,1d] # s, C , 6665.0000000, 1000.0000000, 228.0000000, 64.7100000, 21.0600000, 7.4950000, 2.7970000, 0.5215000 # c, 1.8, 0.0006920, 0.0053290, 0.0270770, 0.1017180, 0.2747400, 0.4485640, 0.2850740, 0.0152040 # s, C , 6665.0000000, 1000.0000000, 228.0000000, 64.7100000, 21.0600000, 7.4950000, 2.7970000, 0.5215000 # c, 1.8, -0.0001460, -0.0011540, -0.0057250, -0.0233120, -0.0639550, -0.1499810, -0.1272620, 0.5445290 # s, C , 0.1596000 # c, 1.1, 1.0000000 # p, C , 9.4390000, 2.0020000, 0.5456000 # c, 1.3, 0.0381090, 0.2094800, 0.5085570 # p, C , 0.1517000 # c, 1.1, 1.0000000 # d, C , 0.5500000 # c, 1.1, 1.0000000 # } # ''') f.write('''symmetry,nosym; orient,noorient; angstrom; geomtype=xyz; geom={ ''') f.write(str(geo.natoms) + '\n') f.write('\n') for i in range(geo.natoms): line_wr = geo.atnames[i] + ' ' + str(r[0, i]) + ' ' + str(r[1, i]) + ' ' + str(r[2, i]) + '\n' # print(file) # print(line_wr) f.write(line_wr) f.write('}\n') f.write('''{multi,failsafe; maxiter,40; ''') line_wr = 'occ,' + str(ab.act_orb) + ';\n' line_wr2 = 'closed,' + str(ab.closed_orb) + ';\n' line_wr3 = 'wf,' + str(ab.n_el) + ',1,0;' line_wr4 = 'state,' + str(3) + ';\n' f.write(line_wr) f.write(line_wr2) f.write(line_wr3) f.write(line_wr4) f.write('''pspace,10.0 orbital,2140.3; ORBITAL,IGNORE_ERROR; ciguess,2501.2 save,ci=2501.2} ''') f.write('''data,copy,2140.3,3000.2 ''') f.write('''{multi,failsafe; maxiter,40; ''') line_wr = 'occ,' + str(ab.act_orb) + ';\n' line_wr2 = 'closed,' + str(ab.closed_orb) + ';\n' line_wr3 = 'wf,' + str(ab.n_el) + ',1,0;' line_wr4 = 'state,' + str(3) + ';\n' f.write(line_wr) f.write(line_wr2) f.write(line_wr3) f.write(line_wr4) f.write('''pspace,10.0 orbital,2140.3; dm,2140.3 save,ci=2501.2 diab,3000.2,save=2140.3} ''') f.write('''{multi,failsafe; maxiter,40; ''') line_wr = 'occ,' + str(ab.act_orb) + ';\n' line_wr2 = 'closed,' + str(ab.closed_orb) + ';\n' line_wr3 = 'wf,' + str(ab.n_el) + ',1,0;' line_wr4 = 'state,' + str(3) + ';\n' f.write(line_wr) f.write(line_wr2) f.write(line_wr3) f.write(line_wr4) f.write('''pspace,10.0 orbital,2140.3; dm,2140.3 save,ci=2501.2 diab,3000.2,save=2140.3 ''') record = 5100.1 for i in range(dyn.nstates): for j in range(i, dyn.nstates): if i == j: f.write('CPMCSCF,GRAD,' + str(i + 1) + '.1,record=' + str(record) + ';\n') record += 1 else: f.write('CPMCSCF,NACM,' + str(i + 1) + '.1,' + str(j + 1) + '.1,' + 'record=' + str(record) + ';\n') record += 1 f.write('}\n') record = 5100.1 for i in range(dyn.nstates): for j in range(i, dyn.nstates): if i == j: f.write('{FORCES;SAMC,' + str(record) + '};\n') record += 1 else: f.write('{FORCES;SAMC,' + str(record) + '};\n') record += 1 f.write('put,molden, ' + file2 + '\n') f.write('''---''') return file2
from src import buildhs import src.ekincorrection as ek print("Number of processors: ", mp.cpu_count()) '''AIMCE propagation''' ''' First, common variables are initialized using the class Traj, based on the dynamics and geometry inputs''' '''q,p initial values, taken from the wigner dist and d,s,a''' '''Remove previous files if needed''' os.system('rm molpro.pun') os.system('rm molpro_traj*') ''' call initial geometry and dynamic parameters along with pyhisical constants''' dyn = initdyn() geo = singlepart() ph = physconst() T1 = initialize_traj.trajectory(1, 3, 1) q = np.zeros(3) q[0] = 4.00 p = np.zeros_like(q) T1.setposition_traj(q) T1.setmomentum_traj(p) T1.setpotential_traj(np.sum(geo.K * q**2 / 2)) T1.setderivs_traj(geo.K * (T1.getposition_traj())) T1.setmass_traj(geo.mass)
def mass2au(partmass): """This function converts the atomic masses in atomic units""" ph = physconst() aum = partmass * ph.amu return aum