Beispiel #1
0
def test_switchfunction():
    Coulomb = coulomb(ip.n_boxes_short_range, ip.L, ip.p_error)
    assert Coulomb._coulomb__switchFunction(1.,1.,2.)==1.,"The switchfunction should be one here."
    assert Coulomb._coulomb__switchFunction(2., 1., 2.) == 0., "The switchfunction should be zero here."

    LJpotential = lennard_jones()
    assert LJpotential._lennard_jones__switchFunction(1.,1.,2.)==1.,"The switchfunction should be one here."
    assert LJpotential._lennard_jones__switchFunction(2., 1., 2.) == 0., "The switchfunction should be zero here."
Beispiel #2
0
    def __init__(self, 
                 positions,
                 properties, 
                 velocities,
                 forces,
                 box,
                 Temperature,
                 Sigma_LJ,
                 Epsilon_LJ, 
                 r_switch,
                 r_cut_LJ,
                 n_boxes_short_range,
                 dt,
                 p_rea,
                 p_error,
                 Symbols):
        #check input parameters
        self.positions=positions
        self.R=np.linalg.norm(self.positions, axis=1)
        self.N = np.size(self.positions[:,0])
        first_d_Pos = np.zeros((self.N,self.N,3))
        first_d_Pos[:,:,0] = np.subtract.outer(self.positions[:,0], self.positions[:,0])
        first_d_Pos[:,:,1] = np.subtract.outer(self.positions[:,1], self.positions[:,1])
        first_d_Pos[:,:,2] = np.subtract.outer(self.positions[:,2], self.positions[:,2])
        self.d_Pos = first_d_Pos
        self.labels=properties
        self.velocities = velocities
        self.forces = forces
        self.L=box
        self.T= Temperature
        
        self.lennard_jones = lennard_jones()
        self.Sigma_LJ = Sigma_LJ
        self.Epsilon_LJ = Epsilon_LJ
        
        
        self.dt = dt
        self.p_rea = p_rea
        self.n_boxes_short_range= n_boxes_short_range

        self.r_switch = r_switch
        self.r_cut_LJ = r_cut_LJ

        # epsilon0 = (8.854 * 10^-12) / (36.938 * 10^-9) -> see Dimension Analysis
        self.coulomb = coulomb(n_boxes_short_range, box, p_error, epsilon0 = epsilon_0 / (36.938 * 10**-9))

        self.neighbours_coulomb, self.distances_coulomb = neighbourlist().compute_neighbourlist(positions, box[0],
                                                                                                0.49 * box[0])
        self.r_cut_coulomb, self.k_cut, self.std = self.coulomb.compute_optimal_cutoff(p_error, box, properties, self.neighbours_coulomb, self.distances_coulomb, r_switch, 0.49 * box[0], positions)
        self.neighbours_coulomb, self.distances_coulomb = neighbourlist().compute_neighbourlist(positions, box[0],
                                                                                                self.r_cut_coulomb)

        self.coulomb.n_boxes_short_range = np.ceil( self.r_cut_coulomb/self.L[0] ).astype(int)
        self.switch_parameter = self.__get_switch_parameter()
        self.neighbours_LJ, self.distances_LJ= neighbourlist().compute_neighbourlist(positions, box[0], self.r_cut_LJ)
        self.Symbols = Symbols

        return
Beispiel #3
0
def test_LJ_forces():
    LJ = lennard_jones()
    Force = LJ.compute_forces(Test_Positions,
                              Sigma,
                              Epsilon,
                              Test_Labels,
                              Test_L,
                              switch_parameter,
                              r_switch,
                              neighbours)
    assert np.all(Force[0, :] == -Force[1, :]), "lennard Jones force is broken"
Beispiel #4
0
def test_SymmetriesPotLJ2():
    potential = lennard_jones()
    result = potential.compute_potential(sigma=ip.sigma, epsilon=ip.epsilon, labels=ip.labels,
                                         distances={0: [np.sqrt(12), np.sqrt(3)], 1: [np.sqrt(12), np.sqrt(12)],
                                                    2: [np.sqrt(3), np.sqrt(12)]},
                                         neighbours=ip.neighbours, r_s=np.sqrt(3 * 2 ** 2),
                                         r_c=np.sqrt(3 * 2 ** 2) + 0.1)
    assert (abs(result[0] / result[2]) < 1 + 10 ** (
    -8)), "Potential does not have the expected symmetrie. P1 and P3 should be the same."
    assert (result[0] != result[1]), "Potential does not have the expected symmetrie. P1 and P2 should not be the same."
    assert (result[2] != result[1]), "Potential does not have the expected symmetrie. P3 and P2 should not be the same."
    return
Beispiel #5
0
def test_SymmetriesPotLJ():
    # tests LJ Potential for  with equidistant identical charges

    potential = lennard_jones()
    result = potential.compute_potential(sigma=ip.sigma, epsilon=ip.epsilon, labels=ip.labels,
                                         distances=ip.distances, neighbours=ip.neighbours, r_s=np.sqrt(3 * 2 ** 2),
                                         r_c=np.sqrt(3 * 2 ** 2) + 0.1)
    assert (abs(result[0] / result[2]) < 1 + 10 ** (
    -8)), "Potential does not have the expected symmetrie. P1 and P3 should be the same."
    assert (abs(result[0] / result[1]) < 1 + 10 ** (
    -8)), "Potential does not have the expected symmetrie. P1 and P2 should be the same."
    assert (abs(result[2] / result[1]) < 1 + 10 ** (
    -8)), "Potential does not have the expected symmetrie. P3 and P2 should be the same."
    return