Example #1
0
    def test_dHdlam(self):
        ha = pot.harmonicOsc(k=1.0, x_shift=-5.0)
        hb = pot.harmonicOsc(k=1.0, x_shift=5.0)
        potential = pot.expCoupledHosc(ha=ha, hb=hb, lam=0)

        positions = np.linspace(-10, 10, num=5)

        # energies only for pot HA
        lam = 0
        potential.set_lam(lam=lam)
        expected_result = np.array([
            4.009080e-001, 4.009080e-001, 0.000, -5.846620e+053, -8.526387e+107
        ])

        energies = potential.dhdlam(positions)

        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_allclose(desired=expected_result,
                                   actual=energies,
                                   err_msg="The results of " + potential.name +
                                   " are not correct wit lambda " + str(lam) +
                                   "!\n\tPositions: " + str(positions) +
                                   "\n\tEnergies: " + str(energies))
Example #2
0
    def test_dHdpos(self):
        phase_shift = 0.0
        multiplicity = 1.0
        amplitude = 1.0
        y_offset = 0.0
        radians = False

        positions = [0, 90, 180, 270, 360]
        expected_result = np.array([0, 2, 0, -2, 0])

        WavePotential = pot.wavePotential(phase_shift=phase_shift,
                                          multiplicity=multiplicity,
                                          amplitude=amplitude,
                                          y_offset=y_offset,
                                          radians=radians)
        WavePotential2 = pot.wavePotential(phase_shift=phase_shift,
                                           multiplicity=multiplicity,
                                           amplitude=amplitude,
                                           y_offset=y_offset,
                                           radians=radians)
        potential = pot.torsionPotential(
            wave_potentials=[WavePotential, WavePotential2])
        energies = potential.dhdpos(positions)

        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(desired=list(expected_result),
                                       actual=list(energies),
                                       err_msg="The results of " +
                                       potential.name + " are not correct!",
                                       decimal=8)
Example #3
0
    def test_dhdpos1DNPos(self):
        ha = pot1.harmonicOsc(x_shift=-5)
        hb = pot1.harmonicOsc(x_shift=5)
        setattr(ha, "nDim", 1)
        setattr(hb, "nDim", 1)

        positions = [5, -5, 2, 0]
        expected_result = np.array(
            [[[10.], [0.], [10.]], [[0.], [0.], [0.]],
             [[7.], [1.0862069], [5.9137931]], [[5.], [2.5], [2.5]]],
            ndmin=2)

        potential = pot.envelopedPotential(V_is=[ha, hb])
        dhdpos = potential.dhdpos(positions)

        self.assertEqual(
            type(expected_result),
            type(dhdpos),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(desired=expected_result,
                                       actual=dhdpos,
                                       err_msg="The results of " +
                                       potential.name + " are not correct!",
                                       decimal=8)
Example #4
0
    def test_check_positions_1DNPosSameState_Iterable_multiPos(self):
        ha = pot1.harmonicOsc(x_shift=-5)
        hb = pot1.harmonicOsc(x_shift=5)
        potential = pot.envelopedPotential(V_is=[ha, hb])

        positions = np.array([4, 2, 3])
        expected = np.array([[[4], [4]], [[2], [2]], [[3], [3]]], ndmin=3)
        checked = potential._check_positions_type_multiPos(positions=positions)

        #print(checked)
        np.testing.assert_equal(checked, expected, "not the same sorry.")
    def testTraj(self):
        integrator = metropolisMonteCarloIntegrator()
        ha = OneD.harmonicOscillatorPotential(x_shift=-5)
        hb = OneD.harmonicOscillatorPotential(x_shift=5)
        pot = OneD.linearCoupledPotentials(Va=ha, Vb=hb)
        sys = perturbedSystem(temperature=300.0,
                              potential=pot,
                              sampler=integrator)

        lam = 0.5
        sys.lam = lam
        ens = self.convBelt(0.0, 1, system=sys)
Example #6
0
    def test_energies_1DNPos(self):
        ha = pot1.harmonicOsc(x_shift=-5)
        hb = pot1.harmonicOsc(x_shift=5)
        potential = pot.envelopedPotential(V_is=[ha, hb])

        positions = [0, 0.5, 1, 2]
        expected = np.array([11.80685282, 10.11828465, 7.9999546, 4.5])
        energies = potential.ene(positions)

        np.testing.assert_almost_equal(energies,
                                       expected,
                                       err_msg="not the same sorry.",
                                       decimal=5)
Example #7
0
    def test_check_positions1DNPos(self):
        ha = pot1.harmonicOsc(x_shift=-5)
        hb = pot1.harmonicOsc(x_shift=5)
        potential = pot.envelopedPotential(V_is=[ha, hb])

        positions = [0, 0.5, 1, 2]
        expected = np.array(
            [[[0], [0]], [[0.5], [0.5]], [[1], [1]], [[2], [2]]], ndmin=2)
        checked = potential._check_positions_type(positions=positions)

        #print(checked)
        np.testing.assert_equal(checked, expected, "not the same sorry.")

        energies = potential.ene(positions)
    def test_run_step(self):
        integrator = metropolisMonteCarloIntegrator()
        ha = OneD.harmonicOscillatorPotential(x_shift=-5)
        hb = OneD.harmonicOscillatorPotential(x_shift=5)
        pot = OneD.linearCoupledPotentials(Va=ha, Vb=hb)
        sys = perturbedSystem(temperature=300.0,
                              potential=pot,
                              sampler=integrator)

        ens = self.convBelt(0.0, 1, system=sys)
        ens.calculate_total_ensemble_energy()
        ens.run()
        ens.calculate_total_ensemble_energy()
        ens.get_replicas_positions()
Example #9
0
    def test_dHdpos(self):
        Vmax = 100
        a = 0
        b = 8

        positions = [0, 0.1, 0.2, 0.5, 1, 2, 3, 6]
        expected_result = np.array([
            0, -0.62490234, -1.24921875, -3.11279297, -6.15234375, -11.71875,
            -16.11328125, -16.40625
        ])

        potential = pot.doubleWellPot(Vmax=Vmax, a=a, b=b)
        energies = potential.dhdpos(positions)

        #print(energies)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(desired=expected_result,
                                       actual=energies,
                                       err_msg="The results of " +
                                       potential.name + " are not correct!",
                                       decimal=2)
Example #10
0
    def redraw_states(self,nstates_event):
        self.nstates = nstates_event["new"]
        
        #Plotting stuff

        for line in self.ax.lines:
            if(line != self.eds_line):
                self.ax.lines.remove(line)
            del line
        
        self.positions_state = np.arange(-4, 4*self.nstates, 0.5)
        self.positions = [[x] for x in  self.positions_state]

        V_is=[pot.harmonicOsc(x_shift=state*4, k=10) for state in range(self.nstates)]
        for state_e in [V.ene(self.positions_state) for V in V_is]:
            self.ax.plot(self.positions_state, state_e, alpha=0.8, lw=5)
        self.ax.set_xlim([-4,(4*self.nstates)])

        
        #pot
        self.Eoffs = self.eds_pot.Eoff_i
        if(len(self.Eoffs)<self.nstates):
            for x in range(len(self.Eoffs), self.nstates):
                self.Eoffs.append(0)
        elif(len(self.Eoffs)>self.nstates):
            self.Eoffs= self.Eoffs[:self.nstates]
        
        self.eoff_sliders_box.children=self.make_eoff_sliders(self.nstates)

        self.eds_pot = potN.envelopedPotential(V_is=V_is, s=np.log10(1+(self.s**1.5/1000)), Eoff_i=self.Eoffs)
        eds_enes = self.eds_pot.ene(self.positions)
        self.eds_line.set_data(self.positions, eds_enes)
        self.fig.canvas.draw()
        self.fig.canvas.flush_events()
Example #11
0
    def test_dHdpos(self):
        c6: float = 1**(-1)
        c12: float = 1**(-1)
        x_shift: float = 0
        y_shift = 0

        positions = [0, 0.1, 0.2, 0.5, 1, 2, 3, 6]
        expected_result = np.array([
            np.inf, 1.19999940 * 10**14, 1.46479687 * 10**10,
            9.75360000 * 10**4, 6.00000000, -4.54101562 * 10**-2,
            -2.73595752 * 10**-3, -2.14325517 * 10**-5
        ])

        potential = pot.lennardJonesPotential(c6=c6,
                                              c12=c12,
                                              x_shift=x_shift,
                                              y_shift=y_shift)
        energies = potential.dhdpos(positions)

        #print(energies)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_allclose(desired=expected_result,
                                   actual=energies,
                                   err_msg="The results of " + potential.name +
                                   " are not correct!")
Example #12
0
    def test_energies(self):
        c6: float = 1**(-1)
        c12: float = 1**(-1)
        x_shift: float = 0
        y_shift = 0

        positions = [0, 0.1, 0.2, 0.5, 1, 2, 3, 6]
        expected_result = np.array([
            np.nan, 9.99999000 * 10**11, 2.44125000 * 10**8,
            4.03200000 * 10**3, 0, -1.53808594 * 10**-2, -1.36986044 * 10**-3,
            -2.14330111 * 10**-5
        ])

        potential = pot.lennardJonesPotential(c6=c6,
                                              c12=c12,
                                              x_shift=x_shift,
                                              y_shift=y_shift)
        energies = potential.ene(positions)

        #print(energies)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(desired=expected_result,
                                       actual=energies,
                                       err_msg="The results of " +
                                       potential.name + " are not correct!",
                                       decimal=2)
Example #13
0
    def test_dHdpos(self):
        q1 = 1
        q2 = 1
        epsilon = 1

        positions = [0, 0.2, 0.5, 1, 2, 360]
        expected_result = np.array([
            -np.inf, -1.98943679, -0.31830988, -0.0795774715, -0.0198943679,
            -0.000000614023700
        ])

        potential = pot.coulombPotential(q1=q1, q2=q2, epsilon=epsilon)
        energies = potential.dhdpos(positions)

        #print(energies)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(desired=list(expected_result),
                                       actual=list(energies),
                                       err_msg="The results of " +
                                       potential.name + " are not correct!",
                                       decimal=8)
Example #14
0
    def test_energies(self):
        q1 = 1
        q2 = 1
        epsilon = 1

        positions = [0, 0.2, 0.5, 1, 2, 360]
        expected_result = np.array([
            np.inf, 0.397887358, 0.159154943, 0.0795774715, 0.0397887358,
            0.000221048532
        ])

        potential = pot.coulombPotential(q1=q1, q2=q2, epsilon=epsilon)
        energies = potential.ene(positions)

        #print(energies)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(desired=list(expected_result),
                                       actual=list(energies),
                                       err_msg="The results of " +
                                       potential.name + " are not correct!",
                                       decimal=8)
Example #15
0
    def __init__(self, potential: pot.envelopedPotential = pot.envelopedPotential(
        V_is=[pot.harmonicOscillatorPotential(x_shift=2), pot.harmonicOscillatorPotential(x_shift=-2)], eoff=[0, 0]),
                 sampler: samplerCls = metropolisMonteCarloIntegrator(),
                 conditions: Iterable[conditionCls] = [],
                 temperature: float = 298.0, start_position: Union[Number, Iterable[Number]] = None,
                 eds_s: float = 1, eds_Eoff: Iterable[Number] = [0, 0]):
        """
            __init__
                construct a eds-System that can be used to manage a simulation.

        Parameters
        ----------
        potential:  pot.envelopedPotential, optional
            potential function class to be explored by sampling
        sampler: sampler, optional
            sampling method, that allows exploring the potential function
        conditions: Iterable[condition], optional
            conditions that shall be applied to the system.
        temperature: float, optional
            The temperature of the system (default: 298K)
        start_position:
            starting position for the simulation and setup of the system.
        eds_s: float, optional
            is the S-value of the EDS-Potential
        eds_Eoff: Iterable[Number], optional
            giving the energy offsets for the

        """
        ################################
        # Declare Attributes
        #################################

        self._currentEdsS = eds_s
        self._currentEdsEoffs = eds_Eoff
        self.state = data.envelopedPStstate

        super().__init__(potential=potential, sampler=sampler, conditions=conditions, temperature=temperature,
                         start_position=start_position)

        # Output
        self.set_s(self._currentEdsS)
        self.set_eoff(self._currentEdsEoffs)
Example #16
0
    def test_init(self):
        integrator = stochastic.metropolisMonteCarloIntegrator()
        potential = OneD.harmonicOscillatorPotential()
        sys = system.system(potential=potential, sampler=integrator)

        replicas = 22
        nsteps = 100
        T_range = range(288, 310)
        setattr(self, "group", None)
        group = replica_exchange.temperatureReplicaExchange(
            system=sys, temperature_range=T_range)
Example #17
0
    def test_simulate_good_exchange(self):
        integrator = stochastic.metropolisMonteCarloIntegrator()
        potential = OneD.harmonicOscillatorPotential()
        sys = system.system(potential=potential, sampler=integrator)

        replicas = 22
        nsteps = 100
        T_range = range(288, 310)
        group = replica_exchange.temperatureReplicaExchange(
            system=sys, temperature_range=T_range)
        ##print(group.get_Total_Energy())
        group.nSteps_between_trials = nsteps
        group.simulate(5)
Example #18
0
    def test_energiesND1Pos_singlePos(self):
        ha = pot1.harmonicOsc(x_shift=-5)
        hb = pot1.harmonicOsc(x_shift=5)

        position = [5, -5]
        expected_result = 61.80685281944005

        potential = pot.envelopedPotential(V_is=[ha, hb])
        potential._set_singlePos_mode()
        energies = potential.ene(position)

        #print(energies)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(desired=expected_result,
                                       actual=energies,
                                       err_msg="The results of " +
                                       potential.name + " are not correct!",
                                       decimal=8)
Example #19
0
def main():
    TRE = replica_exchange.temperatureReplicaExchange

    integrator = stochastic.metropolisMonteCarloIntegrator()
    potential = OneD.harmonicOscillatorPotential()
    sys = system.system(potential=potential, sampler=integrator)

    replicas = 2
    nsteps = 10
    T_range = np.linspace(288, 310, num=replicas)
    group = replica_exchange.temperatureReplicaExchange(
        system=sys, temperature_range=T_range)
    print("TotENERGY:", group.get_replica_total_energies())

    group.nSteps_between_trials = nsteps
    group._run_parallel(1)

    print("FINI: ",
          [traj.shape for key, traj in group.get_trajectories().items()])
Example #20
0
    def test_dHdpos(self):
        x_range = [0, 1]
        y_max = 10
        y_min = 0
        positions = [0, 2, 1, 0.5]
        potential = pot.flat_well(x_range=x_range, y_max=y_max, y_min=y_min)
        expected_result = np.array([0, 0, 0, 0])

        energies = potential.dhdpos(positions)

        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        self.assertListEqual(list(expected_result),
                             list(energies),
                             msg="The results of " + potential.name +
                             " are not correct!")
Example #21
0
    def test_energies(self):
        fc = 1.0
        x_shift = 0.0
        y_shift = 0.0
        positions = [0, 2, 1, 0.5]
        expected_result = np.array([0, 2, 0.5, 0.125])

        potential = pot.harmonicOsc(k=fc, x_shift=x_shift, y_shift=y_shift)
        energies = potential.ene(positions)

        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        self.assertListEqual(list(expected_result),
                             list(energies),
                             msg="The results of " + potential.name +
                             " are not correct!")
Example #22
0
    def test_exchange_all(self):
        integrator = stochastic.metropolisMonteCarloIntegrator()
        potential = OneD.harmonicOscillatorPotential()
        sys = system.system(potential=potential, sampler=integrator)

        T_range = range(1, 10)
        nReplicas = len(T_range)
        positions = {x: float(1) for x in range(nReplicas)}
        velocities = {x: float(0) for x in range(nReplicas)}

        group = replica_exchange.temperatureReplicaExchange(
            system=sys, temperature_range=T_range)
        group.set_replicas_positions(positions)
        group.set_replicas_velocities(velocities)
        group._defaultRandomness = lambda x, y: False

        group.exchange()
        all_exchanges = group._current_exchanges
        finpositions = list(group.get_replicas_positions().values())
        finvelocities = list(group.get_replicas_velocities().values())

        # Checking:
        ##constant params?
        self.assertEqual(len(group.replicas),
                         nReplicas,
                         msg="not enough trajectories were retrieved!")
        self.assertListEqual(
            finpositions,
            list(positions.values()),
            msg="Positions should not change during exchange!")

        #self.assertListEqual(finvelocities, velocities, msg="Velocities should not change during exchange!")
        ##exchange process
        self.assertEqual(nReplicas // 2,
                         len(all_exchanges),
                         msg="length of all exchanges is not correct!")
        self.assertTrue(all(list(all_exchanges.values())),
                        msg="not all exchanges are True!!")
        del group
        setattr(self, "group", None)
Example #23
0
    def test_energies(self):
        Vmax = 100
        a = 0
        b = 8

        positions = np.linspace(-10, 10, num=5)
        expected_result = np.array(
            [31.640625, 37.13378906, 100, 37.13378906, 31.640625])

        potential = pot.doubleWellPot(Vmax=Vmax, a=a, b=b)
        energies = potential.ene(positions)

        #print(energies)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(desired=expected_result,
                                       actual=energies,
                                       err_msg="The results of " +
                                       potential.name + " are not correct!",
                                       decimal=2)
Example #24
0
 def test_constructor(self):
     potential = pot.lennardJonesPotential()
Example #25
0
    def test_dHdpos(self):
        fc = 1.0
        alpha = 1.0
        gamma = 0.0
        lam = 0
        potential = pot.pertHarmonicOsc(fc=fc,
                                        alpha=alpha,
                                        gamma=gamma,
                                        lam=lam)
        positions = np.linspace(-10, 10, num=5)

        #energies only for pot HA
        lam = 0
        potential.set_lam(lam=lam)
        expected_result = np.array([-10, -5, 0, 5, 10])

        energies = potential.dhdpos(positions)

        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(
            desired=expected_result,
            actual=energies,
            err_msg="The results of " + potential.name +
            " are not correct wit lambda " + str(lam) + "!\n\tPositions: " +
            str(positions) + "\n\tEnergies: " + str(energies),
            decimal=2)

        #energies only for pot HB
        lam = 1
        expected_result = np.array([-20, -10, 0, 10, 20])

        potential.set_lam(lam=lam)
        energies = potential.dhdpos(positions)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(
            desired=expected_result,
            actual=energies,
            err_msg="The results of " + potential.name +
            " are not correct wit lambda " + str(lam) + "!\n\tPositions: " +
            str(positions) + "\n\tEnergies: " + str(energies),
            decimal=2)

        #energies merged for pot HB and HA
        lam = 0.5
        expected_result = np.array([-15, -7.5, 0, 7.5, 15])

        potential.set_lam(lam=lam)
        energies = potential.dhdpos(positions)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(
            desired=expected_result,
            actual=energies,
            err_msg="The results of " + potential.name +
            " are not correct wit lambda " + str(lam) + "!\n\tPositions: " +
            str(positions) + "\n\tEnergies: " + str(energies),
            decimal=2)
Example #26
0
 def test_constructor(self):
     potential = pot.pertHarmonicOsc()
Example #27
0
    def test_dHdpos(self):
        ha = pot.harmonicOsc(k=1.0, x_shift=-5.0)
        hb = pot.harmonicOsc(k=1.0, x_shift=5.0)
        potential = pot.expCoupledHosc(ha=ha, hb=hb, lam=0)

        positions = np.linspace(-10, 10, num=5)

        #energies only for pot HA
        lam = 0
        potential.set_lam(lam=lam)
        expected_result = np.array([
            -1304235.5118838537, 0.0, 1.9168317203608185e-05,
            1.469697537672566e-10, 8.451488578640889e-16
        ])

        energies = potential.dhdpos(positions)
        ##print("GOT",  list(energies))
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        #np.testing.assert_almost_equal(desired=expected_result, actual=energies, err_msg="The results of "+potential.name+" are not correct wit lambda "+str(lam)+"!\n\tPositions: "+str(positions)+"\n\tEnergies: "+str(energies), decimal=2)

        #energies only for pot HB
        lam = 1
        expected_result = np.array([
            -2.6622529026263318e+17, -680412108183.5752, -1304235.5118838537,
            0.0, 1.9168317203608185e-05
        ])

        potential.set_lam(lam=lam)
        energies = potential.dhdpos(positions)

        ##print("GOT2",  list(energies))
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        #np.testing.assert_almost_equal(desired=expected_result, actual=energies, err_msg="The results of "+potential.name+" are not correct wit lambda "+str(lam)+"!\n\tPositions: "+str(positions)+"\n\tEnergies: "+str(energies), decimal=2)

        #energies merged for pot HB and HA
        lam = 0.5
        expected_result = np.array([
            -1.331126451319687e+17, -340206054091.7876, -652117.7559323427,
            7.34848768836283e-11, 9.584158602226667e-06
        ])

        potential.set_lam(lam=lam)
        energies = potential.dhdpos(positions)

        ##print("GOT3",  list(energies))
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(
            desired=expected_result,
            actual=energies,
            err_msg="The results of " + potential.name +
            " are not correct wit lambda " + str(lam) + "!\n\tPositions: " +
            str(positions) + "\n\tEnergies: " + str(energies),
            decimal=2)
Example #28
0
    def test_energies(self):
        ha = pot.harmonicOsc(k=1.0, x_shift=-5.0)
        hb = pot.harmonicOsc(k=1.0, x_shift=5.0)
        potential = pot.expCoupledHosc(ha=ha, hb=hb, lam=0)

        positions = np.linspace(-10, 10, num=5)

        # energies only for pot HA
        lam = 0
        expected_result = np.array([12.5, 0, 12.5, 50, 112.5])

        potential.set_lam(lam=lam)
        energies = potential.ene(positions)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(
            desired=expected_result,
            actual=energies,
            err_msg="The results of " + potential.name +
            " are not correct wit lambda " + str(lam) + "!\n\tPositions: " +
            str(positions) + "\n\tEnergies: " + str(energies),
            decimal=2)

        # energies only for pot HB
        lam = 1
        expected_result = np.array([112.5, 50, 12.5, 0, 12.5])

        potential.set_lam(lam=lam)
        energies = potential.ene(positions)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(
            desired=expected_result,
            actual=energies,
            err_msg="The results of " + potential.name +
            " are not correct wit lambda " + str(lam) + "!\n\tPositions: " +
            str(positions) + "\n\tEnergies: " + str(energies),
            decimal=2)

        # energies merged for pot HB and HA
        lam = 0.5
        expected_result = np.array([12.78, 0.28, 12.5, 0.28, 12.78])

        potential.set_lam(lam=lam)
        energies = potential.ene(positions)
        self.assertEqual(
            type(expected_result),
            type(energies),
            msg=
            "returnType of potential was not correct! it should be an np.array"
        )
        np.testing.assert_almost_equal(
            desired=expected_result,
            actual=energies,
            err_msg="The results of " + potential.name +
            " are not correct wit lambda " + str(lam) + "!\n\tPositions: " +
            str(positions) + "\n\tEnergies: " + str(energies),
            decimal=2)
Example #29
0
 def test_constructor(self):
     potential = pot.expCoupledHosc()
Example #30
0
 def test_constructor(self):
     potential = pot.doubleWellPot()