<commit_before>from __future__ import division
from __future__ import print_function
import numpy as np
from scipy.linalg import expm
import sys
import itertools
import copy

class RealTime(object):
    """Class for real-time routines"""
    def __init__(self,mol,numsteps=1000,stepsize=0.1,field=0.0001):
        self.mol = mol
        self.field = field
        self.stepsize = stepsize
        self.numSteps = numsteps
        self.time = np.arange(0,self.numSteps)*self.stepsize
        self.reset()

    def reset(self):
        """Reset all time-dependent property arrays to empty, will also 
           re-do the SCF in order to set the reference back to ground state.
           This will likely need to be changed in the future.
        """
        self.mol.RHF(doPrint=False)
        self.dipole     = []
        self.angmom     = []
        self.Energy     = []
        self.shape = []

    def Magnus2(self,direction='x'):
        self.reset()
        self.mol.orthoDen()
        self.mol.orthoFock()
        h = -1j*self.stepsize
        for idx,time in enumerate(self.time):
            if direction.lower() == 'x':
                self.mol.computeDipole()
                self.dipole.append(np.real(self.mol.mu[0]))
            elif direction.lower() == 'y':
                self.mol.computeDipole()
                self.dipole.append(np.real(self.mol.mu[1]))
            elif direction.lower() == 'z':
                self.mol.computeDipole()
                self.dipole.append(np.real(self.mol.mu[2]))
            self.addField(time,addstep=True,direction=direction)
            curDen  = np.copy(self.mol.PO)
      
            self.addField(time + 0.0*self.stepsize,direction=direction)
            k1 = h*self.mol.FO 
            U = expm(k1)
            self.mol.PO = np.dot(U,np.dot(curDen,self.mol.adj(U))) 
            self.mol.updateFock()
            
            self.addField(time + 1.0*self.stepsize,direction=direction)
            L  = 0.5*(k1 + h*self.mol.FO)
            U  = expm(L)
            self.mol.PO = np.dot(U,np.dot(curDen,self.mol.adj(U))) 
            self.mol.updateFock()
            
            self.mol.unOrthoFock()    
            self.mol.unOrthoDen()    
            self.mol.computeEnergy()
            self.Energy.append(np.real(self.mol.energy))

    def Magnus4(self,direction='x'):
        self.reset()
        self.mol.orthoDen()
        self.mol.orthoFock()
        h = -1j*self.stepsize
        for idx,time in enumerate(self.time):
            if direction.lower() == 'x':
                self.mol.computeDipole()<commit_msg>docstring<commit_after>from __future__ import division
from __future__ import print_function
import numpy as np
from scipy.linalg import expm
import sys
import itertools
import copy

class RealTime(object):
    """Class for real-time routines"""
    def __init__(self,mol,numsteps=1000,stepsize=0.1,field=0.0001):
        self.mol = mol
        self.field = field
        self.stepsize = stepsize
        self.numSteps = numsteps
        self.time = np.arange(0,self.numSteps)*self.stepsize
        self.reset()

    def reset(self):
        """Reset all time-dependent property arrays to empty, will also 
           re-do the SCF in order to set the reference back to ground state.
           This will likely need to be changed in the future.
        """
        self.mol.RHF(doPrint=False)
        self.dipole     = []
        self.angmom     = []
        self.Energy     = []
        self.shape = []

    def Magnus2(self,direction='x'):
        """Propagate in time using the second order explicit Magnus"""
        self.reset()
        self.mol.orthoDen()
        self.mol.orthoFock()
        h = -1j*self.stepsize
        for idx,time in enumerate(self.time):
            if direction.lower() == 'x':
                self.mol.computeDipole()
                self.dipole.append(np.real(self.mol.mu[0]))
            elif direction.lower() == 'y':
                self.mol.computeDipole()
                self.dipole.append(np.real(self.mol.mu[1]))
            elif direction.lower() == 'z':
                self.mol.computeDipole()
                self.dipole.append(np.real(self.mol.mu[2]))
            self.addField(time,addstep=True,direction=direction)
            curDen  = np.copy(self.mol.PO)
      
            self.addField(time + 0.0*self.stepsize,direction=direction)
            k1 = h*self.mol.FO 
            U = expm(k1)
            self.mol.PO = np.dot(U,np.dot(curDen,self.mol.adj(U))) 
            self.mol.updateFock()
            
            self.addField(time + 1.0*self.stepsize,direction=direction)
            L  = 0.5*(k1 + h*self.mol.FO)
            U  = expm(L)
            self.mol.PO = np.dot(U,np.dot(curDen,self.mol.adj(U))) 
            self.mol.updateFock()
            
            self.mol.unOrthoFock()    
            self.mol.unOrthoDen()    
            self.mol.computeEnergy()
            self.Energy.append(np.real(self.mol.energy))

    def Magnus4(self,direction='x'):
        """Propagate in time using the fourth order explicit Magnus"""
        self.reset()
        self.mol.orthoDen()
        self.mol.orthoFock()
        h = -1j*self.stepsize
        for idx,time in enumerate(self.time):
            if direction.lower() == 'x':
                self.mol.computeDipole()
{'fraction_non_alphanumeric': 0.1245765901392548, 'fraction_numerical': 0.010538200978547234, 'mean_word_length': 1.816640169581346, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6387909', 'n_tokens_mistral': 1780, 'n_tokens_neox': 1657, 'n_words': 311}