예제 #1
0
    def __init__(self, fields, dt=1000, molecule=None):
        # Create a Rotor object as the system of interest if not
        # provided by the user
        if molecule is None:
            ## System of interest
            ## Default: a Rotor object with quantum number = const.m
            self.molecule = Rotor(const.m)
        else:
            self.molecule = rotor
        ## Number of time points
        self.n = fields.shape[0]
        ## An nx2 np.ndarray containing the given field.
        ## Each row is the x- and y-component of such field at a time point.
        self.fields = fields
        field_const = 5.142 * 10**11 * 10**(-10)  #amplitude in V/angstrom
        self.fields = self.fields / field_const  #back to atomic units
        self._fields_list = [
            self.fields[i, :].flatten() for i in range(self.n)
        ]
        ## The resulting path from the given fields.
        self.path = np.zeros((self.n, 2))
        ## Time difference between two adjacent time points.
        self.dt = dt
        self._t_final = self.dt * self.n
        ## Time vector containing all time points.
        self.time = np.arange(self._t_final, step=self.dt, dtype=float)
        self.time_in_ps = self.time * 2.418e-5  #time in picoseconds

        #get and set initial field, but not using molecule.update_field()
        field = self._fields_list[0]
        self.molecule.set_field(field)
예제 #2
0
    def setUp(self):
        """instantiation of Rotor object with quantum
        number m.
        
        """

        self.rotor = Rotor(const.m)
예제 #3
0
    def setUp(self):
        """init system with test data for sigmoid"""

        self.rotor = Rotor(const.m)

        fname_fields = 'testdata_solver/fields_real_for_sigmoid_path.txt'
        fname_states = 'testdata_solver/states_for_sigmoid_path.txt'
        self.fields = np.genfromtxt(fname_fields, dtype=float, delimiter=',')
        self.states_expected = np.genfromtxt(fname_states,
                                             dtype=float,
                                             delimiter=',')

        n = 100000
        rotor_period = 2 * np.pi * const.hbar / const.B
        self.t_final = 100 * rotor_period / (2 * np.pi)
        self.dt = self.t_final / n
        self.time = np.arange(self.t_final, step=self.dt, dtype=float)
예제 #4
0
    def __init__(self, path_desired, dt=1000, molecule=None):
        # Create a Rotor object as the system of interest if not
        # provided by the user
        if molecule is None:
            ## System of interest.
            ## Default value is a rotor (solver.molecule.Rotor)
            self.molecule = Rotor(const.m)
        else:
            self.molecule = rotor

        ## Path specified
        self.path = path_desired
        self._path_predicted = np.zeros_like(path_desired)
        ## Number of time points
        self.n = path_desired.shape[0]
        ## Delta t between two adjacent time points.
        self.dt = dt
        self._t_final = self.n * self.dt
        ## Time vector in unit of ?
        self.time = np.arange(self._t_final, step=self.dt, dtype=float)
        self._ddpath = np.stack((f.d2dt2(
            self.path[:, 0], self.dt), f.d2dt2(self.path[:, 1], self.dt)),
                                axis=1)

        # operators used only by private methods within class instance
        m = self.molecule.m
        self._op1 = (f.cosphi(m) + 4 * f.sinphi(m) @ f.ddphi(m) -
                     4 * f.cosphi(m) @ f.d2dphi2(m))
        self._op2 = (f.sinphi(m) - 4 * f.cosphi(m) @ f.ddphi(m) -
                     4 * f.sinphi(m) @ f.d2dphi2(m))
        self._cosphi2 = f.cosphi(m) @ f.cosphi(m)
        self._sinphi2 = f.sinphi(m) @ f.sinphi(m)
        self._cosphi_sinphi = f.cosphi(m) @ f.sinphi(m)
        self._sinphi_cosphi = f.sinphi(m) @ f.cosphi(m)

        #calc and set initial field, but not using molecule.update_field()
        field = self._get_field(0, real=True)
        self.molecule.set_field(field)