Example #1
0
def surface_interaction(m_h_list, couplings):
    """This function is used to calculate the exchange interactions between
  magnetisations defined at the same sites in the mesh."""

    mwes = []
    fields = []
    i = 1
    for m_h_couple in m_h_list:
        m, h = m_h_couple

        m_new_name = "m%d" % i
        h_new_name = "h%d" % i
        i += 1

        mwe_m = ocaml.get_mwe(m)
        mwe_mn = nfem.mwe_sibling(mwe_m, m_new_name, "renamed_m",
                                  [("m", m_new_name)])
        mn = nfem.field_alias(m, mwe_mn)

        mwe_h = ocaml.get_mwe(h)
        mwe_hn = nfem.mwe_sibling(mwe_h, h_new_name, "renamed_h",
                                  [("h_total", h_new_name)])
        hn = nfem.field_alias(h, mwe_hn)

        fields.append(mn)
        fields.append(hn)

        mwes.append(mwe_mn)
        mwes.append(mwe_hn)

    ccode = ccode_surface_interaction
    for ac in couplings:
        i1, i2, m_sat1, m_sat2, ec = ac  # ec is the exchange coupling constant
        ccode += "SURF_INTERACTION(m%d, %f, h%d, m%d, %f, h%d, %f)\n" % \
          (i1, m_sat1, i1, i2, m_sat2, i2, ec)

    original_fn = nfem.site_wise_applicator([], ccode, field_mwes=mwes)

    def fn():
        original_fn([], fields=fields)

    return fn
Example #2
0
def surface_interaction(m_h_list, couplings):
  """This function is used to calculate the exchange interactions between
  magnetisations defined at the same sites in the mesh."""

  mwes = []
  fields = []
  i = 1
  for m_h_couple in m_h_list:
    m, h = m_h_couple

    m_new_name = "m%d" % i
    h_new_name = "h%d" % i
    i += 1

    mwe_m = ocaml.get_mwe(m)
    mwe_mn = nfem.mwe_sibling(mwe_m, m_new_name, "renamed_m", [("m", m_new_name)])
    mn = nfem.field_alias(m, mwe_mn)

    mwe_h = ocaml.get_mwe(h)
    mwe_hn = nfem.mwe_sibling(mwe_h, h_new_name, "renamed_h", [("h_total", h_new_name)])
    hn = nfem.field_alias(h, mwe_hn)

    fields.append( mn )
    fields.append( hn )

    mwes.append( mwe_mn )
    mwes.append( mwe_hn )

  ccode = ccode_surface_interaction
  for ac in couplings:
    i1, i2, m_sat1, m_sat2, ec = ac # ec is the exchange coupling constant
    ccode += "SURF_INTERACTION(m%d, %f, h%d, m%d, %f, h%d, %f)\n" % \
      (i1, m_sat1, i1, i2, m_sat2, i2, ec)

  original_fn = nfem.site_wise_applicator([], ccode, field_mwes=mwes)
  def fn():
    original_fn([], fields=fields)

  return fn
Example #3
0
def renamed_field(field, old_name, new_name):
  mwe = ocaml.get_mwe(field)
  new_mwe = nfem.mwe_sibling(mwe, new_name, "renamed_"+old_name, [(old_name, new_name)])
  return nfem.field_alias(field, new_mwe)
Example #4
0
def renamed_field(field, old_name, new_name):
    mwe = ocaml.get_mwe(field)
    new_mwe = nfem.mwe_sibling(mwe, new_name, "renamed_" + old_name,
                               [(old_name, new_name)])
    return nfem.field_alias(field, new_mwe)