Exemplo n.º 1
0
def relax_system(sim):

    # init_images=[np.load('m_init.npy')]
    """
    n=20
    for i in range(1,n):
        theta = i*np.pi/n
        mx = -np.cos(theta)
        my = np.sin(theta)
        init_images.append((mx,my,0))
    """

    # init_images.append(np.load('m_final.npy'))

    init_images = [(-1, 0, 0), init_dw, (1, 0, 0)]

    neb = NEBM_Cartesian(sim,
                         init_images,
                         interpolations=[6, 6],
                         name='neb',
                         spring_constant=1e8)

    # neb.add_noise(0.1)

    neb.relax(dt=1e-8,
              max_iterations=5000,
              save_vtks_every=500,
              save_npys_every=500,
              stopping_dYdt=100)
def relax_neb(k, maxst, simname, init_im, interp, save_every=10000, coordinates="Cartesian"):
    """
    Execute a simulation with the NEB function of the FIDIMAG code, for an
    elongated particle (long cylinder)

    The simulations are made for a specific spring constant 'k' (a float),
    number of images 'init_im', interpolations between images 'interp'
    (an array) and a maximum of 'maxst' steps.
    'simname' is the name of the simulation, to distinguish the
    output files.

    --> vtks and npys are saved in files starting with the 'simname' string

    """

    # Prepare simulation
    # We define the cylinder with the Magnetisation function
    sim = Sim(mesh)
    sim.Ms = two_part

    # sim.add(UniformExchange(A=A))

    # Uniaxial anisotropy along x-axis
    sim.add(UniaxialAnisotropy(Kx, axis=(1, 0, 0)))

    # Define many initial states close to one extreme. We want to check
    # if the images in the last step, are placed mostly in equally positions
    init_images = init_im

    # Number of images between each state specified before (here we need only
    # two, one for the states between the initial and intermediate state
    # and another one for the images between the intermediate and final
    # states). Thus, the number of interpolations must always be
    # equal to 'the number of initial states specified', minus one.
    interpolations = interp

    if coordinates == "Cartesian":
        neb = NEBM_Cartesian(sim, init_images, interpolations=interpolations, spring_constant=k, name=simname)
    if coordinates == "Spherical":
        neb = NEBM_Spherical(sim, init_images, interpolations=interpolations, spring_constant=k, name=simname)
    if coordinates == "Geodesic":
        neb = NEBM_Geodesic(sim, init_images, interpolations=interpolations, spring_constant=k, name=simname)

    neb.relax(max_iterations=maxst, save_vtks_every=save_every, save_npys_every=save_every, stopping_dYdt=1e-2)
Exemplo n.º 3
0
def relax_system(sim):

    # init_images=[np.load('m_init.npy')]
    """
    n=20
    for i in range(1,n):
        theta = i*np.pi/n
        mx = -np.cos(theta)
        my = np.sin(theta)
        init_images.append((mx,my,0))
    """

    # init_images.append(np.load('m_final.npy'))

    init_images = [(-1, 0, 0), init_dw, (1, 0, 0)]

    neb = NEBM_Cartesian(
        sim, init_images, interpolations=[6, 6], name='neb',
        spring_constant=1e8)

    # neb.add_noise(0.1)

    neb.relax(dt=1e-8, max_iterations=5000, save_vtks_every=500,
              save_npys_every=500, stopping_dYdt=100)
def relax_neb(k, maxst, simname, init_im, interp, save_every=10000,
              coordinates='Cartesian'):
    """
    Execute a simulation with the NEB function of the FIDIMAG code, for an
    elongated particle (long cylinder)

    The simulations are made for a specific spring constant 'k' (a float),
    number of images 'init_im', interpolations between images 'interp'
    (an array) and a maximum of 'maxst' steps.
    'simname' is the name of the simulation, to distinguish the
    output files.

    --> vtks and npys are saved in files starting with the 'simname' string

    """

    # Prepare simulation
    # We define the cylinder with the Magnetisation function
    sim = Sim(mesh)
    sim.Ms = two_part

    #sim.add(UniformExchange(A=A))

    # Uniaxial anisotropy along x-axis
    sim.add(UniaxialAnisotropy(Kx, axis=(1, 0, 0)))

    # Define many initial states close to one extreme. We want to check
    # if the images in the last step, are placed mostly in equally positions
    init_images = init_im

    # Number of images between each state specified before (here we need only
    # two, one for the states between the initial and intermediate state
    # and another one for the images between the intermediate and final
    # states). Thus, the number of interpolations must always be
    # equal to 'the number of initial states specified', minus one.
    interpolations = interp

    if coordinates == 'Cartesian':
        neb = NEBM_Cartesian(sim,
                             init_images,
                             interpolations=interpolations,
                             spring_constant=k,
                             name=simname
                             )
    if coordinates == 'Spherical':
        neb = NEBM_Spherical(sim,
                             init_images,
                             interpolations=interpolations,
                             spring_constant=k,
                             name=simname
                             )
    if coordinates == 'Geodesic':
        neb = NEBM_Geodesic(sim,
                            init_images,
                            interpolations=interpolations,
                            spring_constant=k,
                            name=simname
                            )

    neb.relax(max_iterations=maxst,
              save_vtks_every=save_every,
              save_npys_every=save_every,
              stopping_dYdt=1e-2)