Example #1
0
 def test_get_spin_directions(self):
     configuration.PlusZ(self.p_state)
     nos = system.Get_NOS(self.p_state)
     arr = system.Get_Spin_Directions(self.p_state)
     for i in range(nos):
         self.assertAlmostEqual(arr[i][0], 0.)
         self.assertAlmostEqual(arr[i][1], 0.)
         self.assertAlmostEqual(arr[i][2], 1.)
Example #2
0
def Get_Atom_Types(p_state, idx_image=-1, idx_chain=-1):
    nos = system.Get_NOS(p_state, idx_image, idx_chain)
    ArrayType = ctypes.c_int*nos
    Data = _Get_Atom_Types(ctypes.c_void_p(p_state), 
                           ctypes.c_int(idx_image), ctypes.c_int(idx_chain))
    array_pointer = ctypes.cast(Data, ctypes.POINTER(ArrayType))
    array = np.frombuffer(array_pointer.contents, dtype=ctypes.c_int)
    array_view = array.view()
    return array_view
Example #3
0
def Get_Spin_Positions(p_state, idx_image=-1, idx_chain=-1):
    nos = system.Get_NOS(p_state, idx_image, idx_chain)
    ArrayType = scalar * 3 * nos
    Data = _Get_Spin_Positions(p_state, idx_image, idx_chain)
    array_pointer = ctypes.cast(Data, ctypes.POINTER(ArrayType))
    array = np.frombuffer(array_pointer.contents)
    array_view = array.view()
    array_view.shape = (nos, 3)
    return array_view
Example #4
0
    def test_read(self):
        nos = system.Get_NOS(self.p_state)

        configuration.PlusZ(self.p_state)

        io.Image_Write(self.p_state, io_image_test, 6, "python io test")
        io.Image_Read(self.p_state, io_image_test)
        spins = system.Get_Spin_Directions(self.p_state)
        for i in range(nos):
            self.assertAlmostEqual(spins[i][0], 0.)
            self.assertAlmostEqual(spins[i][1], 0.)
            self.assertAlmostEqual(spins[i][2], 1.)

        configuration.MinusZ(self.p_state)

        io.Image_Write(self.p_state, io_image_test, 6, "python io test")
        io.Image_Read(self.p_state, io_image_test)
        spins = system.Get_Spin_Directions(self.p_state)
        for i in range(nos):
            self.assertAlmostEqual(spins[i][0], 0.)
            self.assertAlmostEqual(spins[i][1], 0.)
            self.assertAlmostEqual(spins[i][2], -1.)
Example #5
0
    sample_temperatures,
    np.linspace(10 + 0.5 * T_step, T_end, num=n_temperatures / 4))

energy_samples = []
magnetization_samples = []
susceptibility_samples = []
specific_heat_samples = []
binder_cumulant_samples = []

cfgfile = "ui-python/input.cfg"  # Input File
with state.State(cfgfile, quiet=True) as p_state:  # State setup
    # Set parameters
    parameters.mc.setOutputGeneral(p_state, False)  # Disallow any output
    geometry.setNCells(p_state, [system_size, system_size, system_size])

    NOS = system.Get_NOS(p_state)

    # Ferromagnet in z-direction
    configuration.PlusZ(p_state)
    # configuration.Random(p_state)

    # Loop over temperatures
    for iT, T in enumerate(sample_temperatures):
        parameters.mc.setTemperature(p_state, T)

        # Cumulative average variables
        E = 0
        E2 = 0
        M = 0
        M2 = 0
        M4 = 0
Example #6
0
 def test_get_nos(self):
     nos = system.Get_NOS(self.p_state)
     self.assertEqual(nos, 4)