How to use oommfc - 10 common examples

To help you get started, we’ve selected a few oommfc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ubermag / oommfc / oommfc / scripts / energy.py View on Github external
mif += f'Specify Oxs_Exchange6Ngbr:{term.name} {{\n'
        mif += f'  default_A {default_value}\n'
        mif += '  atlas :main_atlas\n'
        mif += '  A {\n'
        for key, value in term.A.items():
            if key != 'default':
                if ':' in key:
                    region1, region2 = key.split(':')
                else:
                    region1, region2 = key, key
                mif += f'    {region1} {region2} {value}\n'
        mif += '  }\n'
        mif += '}\n\n'

    elif isinstance(term.A, df.Field):
        Amif, Aname = oc.scripts.setup_scalar_parameter(term.A, 'exchange_A')
        mif = Amif
        mif += '# ExchangePtwise\n'
        mif += f'Specify Oxs_ExchangePtwise:{term.name} {{\n'
        mif += f'  A {Aname}\n'
        mif += '}\n\n'

    return mif
github ubermag / oommfc / oommfc / hamiltonian / exchange.py View on Github external
mif = '# Exchange6Ngbr\n'
            mif += 'Specify Oxs_Exchange6Ngbr {\n'
            mif += f'  default_A {default_value}\n'
            mif += '  atlas :main_atlas\n'
            mif += '  A {\n'
            for key, value in self.A.items():
                if key != 'default':
                    if ':' in key:
                        region1, region2 = key.split(':')
                    else:
                        region1, region2 = key, key
                    mif += f'    {region1} {region2} {value}\n'
            mif += '  }\n'
            mif += '}\n\n'
        elif isinstance(self.A, df.Field):
            Amif, Aname = ou.setup_scalar_parameter(self.A, 'ex_A')
            mif = Amif
            mif += '# ExchangePtwise\n'
            mif += 'Specify Oxs_ExchangePtwise {\n'
            mif += f'  A {Aname}\n'
            mif += '}\n\n'

        return mif
github ubermag / oommfc / oommfc / scripts / energy.py View on Github external
def magnetoelastic_script(term, system):
    B1mif, B1name = oc.scripts.setup_scalar_parameter(term.B1, 'mel_B1')
    B2mif, B2name = oc.scripts.setup_scalar_parameter(term.B2, 'mel_B2')
    ediagmif, ediagname = oc.scripts.setup_vector_parameter(
        term.e_diag, 'mel_ediag')
    eoffdiagmif, eoffdiagname = oc.scripts.setup_vector_parameter(
        term.e_offdiag, 'mel_eoffdiag')

    mif = ''
    mif += B1mif
    mif += B2mif
    mif += ediagmif
    mif += eoffdiagmif
    mif += '# MagnetoElastic\n'
    mif += f'Specify YY_FixedMEL:{term.name} {{\n'
    mif += f'  B1 {B1name}\n'
    mif += f'  B2 {B2name}\n'
    mif += f'  e_diag_field {ediagname}\n'
    mif += f'  e_offdiag_field {eoffdiagname}\n'
github ubermag / oommfc / oommfc / scripts / energy.py View on Github external
def cubicanisotropy_script(term, system):
    kmif, kname = oc.scripts.setup_scalar_parameter(term.K, 'ca_K')
    u1mif, u1name = oc.scripts.setup_vector_parameter(term.u1, 'ca_u1')
    u2mif, u2name = oc.scripts.setup_vector_parameter(term.u2, 'ca_u2')

    mif = ''
    mif += kmif
    mif += u1mif
    mif += u2mif
    mif += '# CubicAnisotropy\n'
    mif += f'Specify Oxs_CubicAnisotropy:{term.name} {{\n'
    mif += f'  K1 {kname}\n'
    mif += f'  axis1 {u1name}\n'
    mif += f'  axis2 {u2name}\n'
    mif += '}\n\n'

    return mif
github ubermag / oommfc / oommfc / scripts / energy.py View on Github external
def magnetoelastic_script(term, system):
    B1mif, B1name = oc.scripts.setup_scalar_parameter(term.B1, 'mel_B1')
    B2mif, B2name = oc.scripts.setup_scalar_parameter(term.B2, 'mel_B2')
    ediagmif, ediagname = oc.scripts.setup_vector_parameter(
        term.e_diag, 'mel_ediag')
    eoffdiagmif, eoffdiagname = oc.scripts.setup_vector_parameter(
        term.e_offdiag, 'mel_eoffdiag')

    mif = ''
    mif += B1mif
    mif += B2mif
    mif += ediagmif
    mif += eoffdiagmif
    mif += '# MagnetoElastic\n'
    mif += f'Specify YY_FixedMEL:{term.name} {{\n'
    mif += f'  B1 {B1name}\n'
    mif += f'  B2 {B2name}\n'
    mif += f'  e_diag_field {ediagname}\n'
github ubermag / oommfc / oommfc / scripts / evolver.py View on Github external
def evolver_script(evolver):
    mif = ''

    # Prepare parameters depending on what attributes are defined in evolver.
    if hasattr(evolver, 'gamma_G'):
        gamma0mif, gamma0name = oc.scripts.setup_scalar_parameter(
            evolver.gamma_G, 'pr_gamma0')
        evolver.gamma_G = gamma0name
        mif += gamma0mif
    if hasattr(evolver, 'alpha'):
        alphamif, alphaname = oc.scripts.setup_scalar_parameter(
            evolver.alpha, 'dp_alpha')
        evolver.alpha = alphaname
        mif += alphamif
    if hasattr(evolver, 'u'):
        umif, uname = oc.scripts.setup_scalar_parameter(evolver.u, 'zl_u')
        evolver.u = uname
        mif += umif

    # zhangli.beta cannot spatially vary - it has to be a constant.

    if hasattr(evolver, 'J'):
        Jmif, Jname = oc.scripts.setup_scalar_parameter(evolver.J, 'sl_J')
        evolver.J = Jname
        mif += Jmif
    if hasattr(evolver, 'mp'):
        mpmif, mpname = oc.scripts.setup_vector_parameter(evolver.mp, 'sl_mp')
github ubermag / oommfc / oommfc / scripts / evolver.py View on Github external
def evolver_script(evolver):
    mif = ''

    # Prepare parameters depending on what attributes are defined in evolver.
    if hasattr(evolver, 'gamma_G'):
        gamma0mif, gamma0name = oc.scripts.setup_scalar_parameter(
            evolver.gamma_G, 'pr_gamma0')
        evolver.gamma_G = gamma0name
        mif += gamma0mif
    if hasattr(evolver, 'alpha'):
        alphamif, alphaname = oc.scripts.setup_scalar_parameter(
            evolver.alpha, 'dp_alpha')
        evolver.alpha = alphaname
        mif += alphamif
    if hasattr(evolver, 'u'):
        umif, uname = oc.scripts.setup_scalar_parameter(evolver.u, 'zl_u')
        evolver.u = uname
        mif += umif

    # zhangli.beta cannot spatially vary - it has to be a constant.

    if hasattr(evolver, 'J'):
        Jmif, Jname = oc.scripts.setup_scalar_parameter(evolver.J, 'sl_J')
        evolver.J = Jname
        mif += Jmif
    if hasattr(evolver, 'mp'):
        mpmif, mpname = oc.scripts.setup_vector_parameter(evolver.mp, 'sl_mp')
        evolver.mp = mpname
        mif += mpmif
    if hasattr(evolver, 'P'):
        Pmif, Pname = oc.scripts.setup_scalar_parameter(evolver.P, 'sl_P')
        evolver.P = Pname
github ubermag / oommfc / oommfc / scripts / energy.py View on Github external
def uniaxialanisotropy_script(term, system):
    umif, uname = oc.scripts.setup_vector_parameter(term.u, 'ua_u')

    # Determine if higher-order anisotropy is defined
    if isinstance(term.K2, (numbers.Real, dict, df.Field)):
        k1mif, k1name = oc.scripts.setup_scalar_parameter(term.K1, 'ua_K1')
        k2mif, k2name = oc.scripts.setup_scalar_parameter(term.K2, 'ua_K2')

        mif = ''
        mif += k1mif
        mif += k2mif
        mif += umif
        mif += '# UniaxialAnisotropy\n'
        mif += f'Specify Southampton_UniaxialAnisotropy4:{term.name} {{\n'
        mif += f'  K1 {k1name}\n'
        mif += f'  K2 {k2name}\n'
        mif += f'  axis {uname}\n'
        mif += '}\n\n'

    else:
        kmif, kname = oc.scripts.setup_scalar_parameter(term.K, 'ua_K')

        mif = ''
github ubermag / oommfc / oommfc / scripts / energy.py View on Github external
k1mif, k1name = oc.scripts.setup_scalar_parameter(term.K1, 'ua_K1')
        k2mif, k2name = oc.scripts.setup_scalar_parameter(term.K2, 'ua_K2')

        mif = ''
        mif += k1mif
        mif += k2mif
        mif += umif
        mif += '# UniaxialAnisotropy\n'
        mif += f'Specify Southampton_UniaxialAnisotropy4:{term.name} {{\n'
        mif += f'  K1 {k1name}\n'
        mif += f'  K2 {k2name}\n'
        mif += f'  axis {uname}\n'
        mif += '}\n\n'

    else:
        kmif, kname = oc.scripts.setup_scalar_parameter(term.K, 'ua_K')

        mif = ''
        mif += kmif
        mif += umif
        mif += '# UniaxialAnisotropy\n'
        mif += f'Specify Oxs_UniaxialAnisotropy:{term.name} {{\n'
        mif += f'  K1 {kname}\n'
        mif += f'  axis {uname}\n'
        mif += '}\n\n'

    return mif
github ubermag / oommfc / oommfc / scripts / evolver.py View on Github external
mif += Jmif
    if hasattr(evolver, 'mp'):
        mpmif, mpname = oc.scripts.setup_vector_parameter(evolver.mp, 'sl_mp')
        evolver.mp = mpname
        mif += mpmif
    if hasattr(evolver, 'P'):
        Pmif, Pname = oc.scripts.setup_scalar_parameter(evolver.P, 'sl_P')
        evolver.P = Pname
        mif += Pmif
    if hasattr(evolver, 'Lambda'):
        Lambdamif, Lambdaname = oc.scripts.setup_scalar_parameter(
            evolver.Lambda, 'sl_Lambda')
        evolver.Lambda = Lambdaname
        mif += Lambdamif
    if hasattr(evolver, 'eps_prime'):
        eps_primemif, eps_primename = oc.scripts.setup_scalar_parameter(
            evolver.eps_prime, 'sl_eps_prime')
        evolver.eps_prime = eps_primename
        mif += eps_primemif

    # Scripts for a specific evolver.
    if isinstance(evolver, oc.EulerEvolver):
        mif += '# EulerEvolver\n'
        mif += 'Specify Oxs_EulerEvolve:evolver {\n'
    elif isinstance(evolver, oc.RungeKuttaEvolver):
        mif += '# RungeKuttaEvolver\n'
        mif += 'Specify Oxs_RungeKuttaEvolve:evolver {\n'
    elif isinstance(evolver, oc.SpinTEvolver):
        mif += '# Zhang-Li evolver\n'
        mif += 'Specify Anv_SpinTEvolve:evolver {\n'
    elif isinstance(evolver, oc.SpinXferEvolver):
        mif += '# Slonczewski evolver\n'