Пример #1
0
 def new_mwe_and_field(self, name, indices=[], where=None, initial_values=set_to_zero):
   if where == None: where = self.where
   element = nfem.make_element(name, indices, self.mesh.dim, self.order)
   associations = list((body_nr, element) for body_nr in where)
   mwe = nfem.make_mwe(name, associations, mesh=self.mesh)
   field = nfem.make_field(mwe, initial_values=field_function(initial_values))
   self.mwes[name] = mwe
   self.fields[name] = field
   return (mwe, field)
Пример #2
0
 def new_mwe_and_field(self,
                       name,
                       indices=[],
                       where=None,
                       initial_values=set_to_zero):
     if where == None: where = self.where
     element = nfem.make_element(name, indices, self.mesh.dim, self.order)
     associations = list((body_nr, element) for body_nr in where)
     mwe = nfem.make_mwe(name, associations, mesh=self.mesh)
     field = nfem.make_field(mwe,
                             initial_values=field_function(initial_values))
     self.mwes[name] = mwe
     self.fields[name] = field
     return (mwe, field)
Пример #3
0
element_J = nfem.make_element("J", [2])

mwe_sigma = nfem.make_mwe("mwe_sigma", [(1, element_sigma)])
mwe_drho_by_dt = nfem.make_mwe("mwe_drho_by_dt", [(1, element_drho_by_dt)])
mwe_phi = nfem.make_mwe("mwe_phi", [(1, element_phi)])
mwe_J = nfem.make_mwe("mwe_J", [(1, element_J)])

diffop_laplace = nfem.diffop("-<d/dxj drho_by_dt|sigma|d/dxj phi>, j:2")
diffop_J = nfem.diffop("<J(k)|sigma|d/dxk phi>, k:2")


def fun_sigma0(dof_name_indices, position):
    return sigma0


field_sigma = nfem.make_field(mwe_sigma, fun_sigma0)


def fun_sigma0(dof_name_indices, position):
    return sigma0


# Later on, we will modify this field:

field_sigma = nfem.make_field(mwe_sigma, fun_sigma0)


#this line causes a crash
def laplace_dbc(dof_name_indices, coord):

    ##where as this one works.
Пример #4
0
mwe_sigma      = nfem.make_mwe("mwe_sigma",     [(1,element_sigma)])
mwe_drho_by_dt = nfem.make_mwe("mwe_drho_by_dt",[(1,element_drho_by_dt)])
mwe_phi        = nfem.make_mwe("mwe_phi",       [(1,element_phi)])
mwe_J          = nfem.make_mwe("mwe_J",         [(1,element_J)])

diffop_laplace=nfem.diffop("-<d/dxj drho_by_dt|sigma|d/dxj phi>, j:2")
diffop_J=nfem.diffop("<J(k)|sigma|d/dxk phi>, k:2")

# Initial conductivity is spatially constant:

def fun_sigma0(dof_name_indices,position):
    return sigma0

# Later on, we will modify this field:

field_sigma=nfem.make_field(mwe_sigma,fun_sigma0)

# Dirichlet Boundary Conditions on our sample:

def laplace_dbc(coords):
    if(abs(coords[1]) > (2.5-0.05)):
        return 1
    else:
        return 0

def laplace_dbc_values(dof_name_indices,coords):
    if(coords[1] > 0.0):
        return 1.0
    else:
        return -1.0    
Пример #5
0
prematrix_laplace=nfem.prematrix(diffop_laplace,mwe_rho_M,mwe_phi_M)
prematrix_div_M=nfem.prematrix(diffop_div_M,mwe_rho_M,mwe_M,ignore_jumps=False)
prematrix_grad_phi=nfem.prematrix(diffop_grad_phi,mwe_H,mwe_phi_M)

log.info("OK 3!")

solve_bem=nfem.laplace_solver_bem(prematrix_laplace,inside_regions=[1])

log.info("OK 4!")

compute_div_M=nfem.prematrix_applicator(prematrix_div_M,interface_coeffs=[(1,-1,1.0)])
compute_grad_phi=nfem.prematrix_applicator(prematrix_grad_phi)

log.info("OK 5!")

field_M0=nfem.make_field(mwe_M,fun_M0)

cofield_div_M=compute_div_M(field_M0)

# DDD
ddd_field_div_M=nfem.cofield_to_field(cofield_div_M)
print "DDD div M: ",nfem.probe_field(ddd_field_div_M,[2.7,0.2,0.0]) # we may add: ,name_stem="rho_M")
# END DDD

field_phi_M=solve_bem(cofield_div_M)

log.info("OK 6!")
field_H=nfem.cofield_to_field(compute_grad_phi(field_phi_M))

log.info("OK 7!")
# Also, we do direct summation, just for comparison:
Пример #6
0
mwe_M = nfem.make_mwe("mwe_M", [(1, element_M)])
mwe_H = nfem.make_mwe("mwe_H", [(1, element_H)])

diffop_v_laplace = nfem.diffop("-<d/dxj H(k) || d/dxj M(k)>, j:3, k:3")


# Note that this magnetization is "mostly zero":
def fun_M0(dof_name_indices, position):
    if dof_name_indices[1][0] == 1:  # y-direction
        x = position[0]
        return 1.0 / (1.0 + (x * x / 4.0))
    else:
        return 0.0


field_M = nfem.make_field(mwe_M, fun_M0)

prematrix_v_laplace = nfem.prematrix(diffop_v_laplace, mwe_H, mwe_M)

v_laplace = nfem.prematrix_applicator(prematrix_v_laplace)

field_H = nfem.cofield_to_field(v_laplace(field_M))

range_i = 100

# nfem.field_print_contents(field_H)

for i in range(0, range_i):
    pos = [-4.5 + 9.0 * i / (0.0 + range_i), 0.0, 0.0]
    field_val = nfem.probe_field(field_H, "H", pos)
    print pos[0], " ", field_val[1]
Пример #7
0
mwe_M      = nfem.make_mwe("mwe_M", [(1,element_M)])
mwe_H      = nfem.make_mwe("mwe_H", [(1,element_H)])

diffop_v_laplace = nfem.diffop("-<d/dxj H(k) || d/dxj M(k)>, j:3, k:3")

# Note that this magnetization is "mostly zero":
def fun_M0(dof_name_indices,position):
    if dof_name_indices[1][0]==1: # y-direction
        x=position[0]
        return 1.0/(1.0+(x*x/4.0))
    else:
        return 0.0


field_M=nfem.make_field(mwe_M,fun_M0)

prematrix_v_laplace=nfem.prematrix(diffop_v_laplace,mwe_H,mwe_M)

v_laplace=nfem.prematrix_applicator(prematrix_v_laplace)

field_H=nfem.cofield_to_field(v_laplace(field_M))

range_i=100

# nfem.field_print_contents(field_H)

for i in range(0,range_i):
    pos=[-4.5+9.0*i/(0.0+range_i),0.0,0.0]
    field_val=nfem.probe_field(field_H,"H",pos)
    print pos[0], " ", field_val[1]
Пример #8
0
mwe2d_M      = nfem.make_mwe("mwe2d_M",     [(1,elem2d_M)])
mwe2d_H      = nfem.make_mwe("mwe2d_H",     [(1,elem2d_H)])
mwe2d_rho_M  = nfem.make_mwe("mwe2d_rho_M", [(1,elem2d_rho_M)])
mwe2d_phi_M  = nfem.make_mwe("mwe2d_phi_M", [(1,elem2d_phi_M)])

#This is " $\ laplace -phi = =rho_M$
pmx2d_laplace=nfem.prematrix(diffop_laplace,mwe2d_rho_M,mwe2d_phi_M)
pmx2d_div_M=nfem.prematrix(diffop_div_M,mwe2d_rho_M,mwe2d_M,ignore_jumps=False)
pmx2d_grad_phi=nfem.prematrix(diffop_grad_phi,mwe2d_H,mwe2d_phi_M)

solve_bem_2d=nfem.laplace_solver_bem(pmx2d_laplace,inside_regions=[1], thickness=thickness2d)

compute_div_M_2d=nfem.prematrix_applicator(pmx2d_div_M,interface_coeffs=[(1,-1,1.0)])
compute_grad_phi_2d=nfem.prematrix_applicator(pmx2d_grad_phi)

field2d_M0=nfem.make_field(mwe2d_M,fun_M0)

cofield2d_div_M=compute_div_M_2d(field2d_M0)

field2d_phi_M=solve_bem_2d(cofield2d_div_M)

field2d_H=nfem.cofield_to_field(compute_grad_phi_2d(field2d_phi_M))

# DDDDDD

print "phi_M left: ",nfem.probe_field(field2d_phi_M,[-3.8,0.0])
print "phi_M right: ",nfem.probe_field(field2d_phi_M,[3.8,0.0])

nfem.plot_scalar_field(field2d_phi_M,
                        "phi_M","/tmp/plot-phi-M.ps",
                        plot_edges=False,
Пример #9
0
diffop_v_laplace = nfem.diffop("-<d/dxj H(k) || d/dxj M(k)>, j:3, k:3")

print "Made MWEs"
sys.stdout.flush()

# Note that this magnetization is "mostly zero":
def fun_M0(dof_name_indices,position):
    if dof_name_indices[1][0]==1: # y-direction
        x=position[0]
        return 1.0/(1.0+(x*x/4.0))
    else:
        return 0.0

# MMM

field_M2=nfem.make_field(mwe_M2,fun_M0)

print "Made M2"
sys.stdout.flush()


diffop_m_m2 = nfem.diffop("<M(j) || M2(j)>, j:3")
prematrix_m_m2=nfem.prematrix(diffop_m_m2,mwe_M,mwe_M2)

print "Made M2->M prematrix"
sys.stdout.flush()


m_m2=nfem.prematrix_applicator(prematrix_m_m2)

field_M=nfem.cofield_to_field(m_m2(field_M2))
Пример #10
0
  def setup(self):
    '''This function should be called after the method 'set' to setup
       the simulation (create the fields, the operators and so on)'''

    # Should not do initializizations more than once
    if self.is_ready: return

    mwe_m, field_m = self.new_mwe_and_field("m", [3], initial_values=self.initial_mag)
    mwe_h_total, field_h_total = self.new_mwe_and_field("h_total", [3])

    if self.features["include_demag"]:
      self.new_field("h_demag", indices=[3])
    if self.features["include_exchange"]:
      self.new_field("h_exch", indices=[3])
    if self.features["external_field"]:
      h0 = self.features["external_field"]
      self.new_field("h_ext", indices=[3], initial_values=h0)

    # The demag field
    if self.features["include_demag"]:
      if self.mesh.dim != 3:
        raise "Sorry, the demag-calculation is implemented only for 3-D space."

      mwe_h_demag = self.mwes["h_demag"]
      field_h_demag = self.fields["h_demag"]

      mwe_scalar = self.new_mwe("scalar")
      mwe_rho_m = nfem.mwe_sibling(mwe_scalar, "mwe_rho_m", "renamed_scalar", [("scalar", "rho_m")])
      mwe_phi_m = nfem.mwe_sibling(mwe_scalar, "mwe_phi_m", "renamed_scalar", [("scalar", "phi_m")])

      field_div_m = nfem.make_field(mwe_rho_m)
      field_phi_m = nfem.make_field(mwe_phi_m)

      diffop_div_m_str = "%f <rho_m||d/dxj m(j)>, j:3" % self.m_sat
      print diffop_div_m_str
      compute_div_m = \
       nfem.diffop_applicator(diffop_div_m_str,
                              mwe_rho_m, mwe_m,
                              interface_coeffs=[(-2,-2,1.0)],
                              petsc_name="mumag_div_m")

      prematrix_laplace = \
       nfem.prematrix("-<d/dxj rho_m||d/dxj phi_m>, j:3", mwe_rho_m, mwe_phi_m)

      solve_bem = \
       nfem.laplace_solver_bem(prematrix_laplace, inside_regions=self.where)

      compute_grad_phi = \
       nfem.diffop_applicator("<h_demag(j)||d/dxj phi_m>, j:3",
                              mwe_h_demag, mwe_phi_m, result="field")

      cofield_div_m = compute_div_m(self.fields["m"])
      solve_bem(cofield_div_m, target=field_phi_m)
      compute_grad_phi(field_phi_m, target=field_h_demag)

      def calculate_h_demag():
        compute_div_m(self.fields["m"], target=cofield_div_m)
        solve_bem(cofield_div_m, target=field_phi_m)
        compute_grad_phi(field_phi_m, target=field_h_demag)

      self.calculate_h_demag = calculate_h_demag

    # Now we add the exchange and demag fields if needed
    if self.features["include_exchange"]:
      if not self.features["exchange_coupling"]:
        raise "You want to include exchange interaction, " + \
         "but you did not specify the exchange coupling constant!"
      ec = self.features["exchange_coupling"]
      if ec < 0.0:
        raise "Error: you specified a negative exchange coupling constant."
      mwe_h_exch = self.mwes["h_exch"]
      field_h_exch = self.fields["h_exch"]
      exch_factor  = -2.0*ec/self.m_sat_mu0
      op_str = "%f <d/dxi h_exch(j) || d/dxi m(j)>, i:%d, j:3" % (exch_factor, self.mesh.dim)
      op_h_exch = nfem.diffop(op_str)
      p = nfem.prematrix(op_h_exch, mwe_h_exch, mwe_m, ignore_jumps=True)
      compute_h_exch = nfem.prematrix_applicator(p)
      h_exch_cofield = compute_h_exch(field_m)
      nfem.cofield_to_field(h_exch_cofield, target=field_h_exch)
      def calculate_h_exch():
        compute_h_exch(field_m, target=h_exch_cofield)
        nfem.cofield_to_field(h_exch_cofield, target=field_h_exch)

      self.calculate_h_exch = calculate_h_exch

    # Create the C-functions which performs the different parts
    # of the computation

    some_names = ["m", "h_total"]
    some_mwes = self.mwe_list(some_names)
    some_fields = self.field_list(some_names)

    if self.uniaxial_anis:
      args = ["m_sat_mu0", "axis_x", "axis_y", "axis_z", "k1", "k2"]
      c_uniaxial = nfem.site_wise_applicator(args, ccode_uniaxial, field_mwes=some_mwes)
      def calculate_uniaxial_anis():
        for ua in self.uniaxial_anis:
          axis, k1, k2 = ua
          axis_x, axis_y, axis_z = axis
          args_values = [self.m_sat_mu0, axis_x, axis_y, axis_z, k1, k2]
          c_uniaxial(args_values, fields=some_fields)

      self.calculate_uniaxial_anis = calculate_uniaxial_anis

    if self.cubic_anis:
      args = ["m_sat_mu0", "axis1_x", "axis1_y", "axis1_z",
       "axis2_x", "axis2_y", "axis2_z", "k1", "k2", "k3"]
      c_cubic = nfem.site_wise_applicator(args, ccode_cubic, field_mwes=some_mwes)
      def calculate_cubic_anis():
        for ca in self.cubic_anis:
          axis1, axis2, k1, k2, k3 = ca
          axis1_x, axis1_y, axis1_z = axis1
          axis2_x, axis2_y, axis2_z = axis2
          args_values = [self.m_sat_mu0, axis1_x, axis1_y, axis1_z,
          axis2_x, axis2_y, axis2_z, k1, k2, k3]
          c_cubic(args_values, fields=some_fields)
      self.calculate_cubic_anis = calculate_cubic_anis

    more_names = ["h_total", "h_ext", "h_demag", "h_exch"]
    more_mwes = self.mwe_list(more_names)
    more_fields = self.field_list(more_names)
    add_fields = nfem.site_wise_applicator([], ccode_add_fields, field_mwes=more_mwes)
    def add_ext_demag_exch():
      add_fields([], fields=more_fields)
    self.add_ext_demag_exch = add_ext_demag_exch

    if self.features["calculate_energy"]:
      swa_calculate_energy = \
       nfem.site_wise_applicator(["energy"], ccode_calculate_energy,
                                 field_mwes=[mwe_m],cofield_mwes=[mwe_h_total])
      cofield_h_total = nfem.field_to_cofield(field_h_total)
      def calculate_energy():
        nfem.field_to_cofield(field_h_total, target=cofield_h_total)
        energy = swa_calculate_energy([0.0], fields=[field_m], cofields=[cofield_h_total])
        return -self.m_sat_mu0*energy[0]
      self.__calculate_energy = calculate_energy

    self.is_ready = True
Пример #11
0
    def setup(self):
        '''This function should be called after the method 'set' to setup
       the simulation (create the fields, the operators and so on)'''

        # Should not do initializizations more than once
        if self.is_ready: return

        mwe_m, field_m = self.new_mwe_and_field(
            "m", [3], initial_values=self.initial_mag)
        mwe_h_total, field_h_total = self.new_mwe_and_field("h_total", [3])

        if self.features["include_demag"]:
            self.new_field("h_demag", indices=[3])
        if self.features["include_exchange"]:
            self.new_field("h_exch", indices=[3])
        if self.features["external_field"]:
            h0 = self.features["external_field"]
            self.new_field("h_ext", indices=[3], initial_values=h0)

        # The demag field
        if self.features["include_demag"]:
            if self.mesh.dim != 3:
                raise "Sorry, the demag-calculation is implemented only for 3-D space."

            mwe_h_demag = self.mwes["h_demag"]
            field_h_demag = self.fields["h_demag"]

            mwe_scalar = self.new_mwe("scalar")
            mwe_rho_m = nfem.mwe_sibling(mwe_scalar, "mwe_rho_m",
                                         "renamed_scalar",
                                         [("scalar", "rho_m")])
            mwe_phi_m = nfem.mwe_sibling(mwe_scalar, "mwe_phi_m",
                                         "renamed_scalar",
                                         [("scalar", "phi_m")])

            field_div_m = nfem.make_field(mwe_rho_m)
            field_phi_m = nfem.make_field(mwe_phi_m)

            diffop_div_m_str = "%f <rho_m||d/dxj m(j)>, j:3" % self.m_sat
            print diffop_div_m_str
            compute_div_m = \
             nfem.diffop_applicator(diffop_div_m_str,
                                    mwe_rho_m, mwe_m,
                                    interface_coeffs=[(-2,-2,1.0)],
                                    petsc_name="mumag_div_m")

            prematrix_laplace = \
             nfem.prematrix("-<d/dxj rho_m||d/dxj phi_m>, j:3", mwe_rho_m, mwe_phi_m)

            solve_bem = \
             nfem.laplace_solver_bem(prematrix_laplace, inside_regions=self.where)

            compute_grad_phi = \
             nfem.diffop_applicator("<h_demag(j)||d/dxj phi_m>, j:3",
                                    mwe_h_demag, mwe_phi_m, result="field")

            cofield_div_m = compute_div_m(self.fields["m"])
            solve_bem(cofield_div_m, target=field_phi_m)
            compute_grad_phi(field_phi_m, target=field_h_demag)

            def calculate_h_demag():
                compute_div_m(self.fields["m"], target=cofield_div_m)
                solve_bem(cofield_div_m, target=field_phi_m)
                compute_grad_phi(field_phi_m, target=field_h_demag)

            self.calculate_h_demag = calculate_h_demag

        # Now we add the exchange and demag fields if needed
        if self.features["include_exchange"]:
            if not self.features["exchange_coupling"]:
                raise "You want to include exchange interaction, " + \
                 "but you did not specify the exchange coupling constant!"
            ec = self.features["exchange_coupling"]
            if ec < 0.0:
                raise "Error: you specified a negative exchange coupling constant."
            mwe_h_exch = self.mwes["h_exch"]
            field_h_exch = self.fields["h_exch"]
            exch_factor = -2.0 * ec / self.m_sat_mu0
            op_str = "%f <d/dxi h_exch(j) || d/dxi m(j)>, i:%d, j:3" % (
                exch_factor, self.mesh.dim)
            op_h_exch = nfem.diffop(op_str)
            p = nfem.prematrix(op_h_exch, mwe_h_exch, mwe_m, ignore_jumps=True)
            compute_h_exch = nfem.prematrix_applicator(p)
            h_exch_cofield = compute_h_exch(field_m)
            nfem.cofield_to_field(h_exch_cofield, target=field_h_exch)

            def calculate_h_exch():
                compute_h_exch(field_m, target=h_exch_cofield)
                nfem.cofield_to_field(h_exch_cofield, target=field_h_exch)

            self.calculate_h_exch = calculate_h_exch

        # Create the C-functions which performs the different parts
        # of the computation

        some_names = ["m", "h_total"]
        some_mwes = self.mwe_list(some_names)
        some_fields = self.field_list(some_names)

        if self.uniaxial_anis:
            args = ["m_sat_mu0", "axis_x", "axis_y", "axis_z", "k1", "k2"]
            c_uniaxial = nfem.site_wise_applicator(args,
                                                   ccode_uniaxial,
                                                   field_mwes=some_mwes)

            def calculate_uniaxial_anis():
                for ua in self.uniaxial_anis:
                    axis, k1, k2 = ua
                    axis_x, axis_y, axis_z = axis
                    args_values = [
                        self.m_sat_mu0, axis_x, axis_y, axis_z, k1, k2
                    ]
                    c_uniaxial(args_values, fields=some_fields)

            self.calculate_uniaxial_anis = calculate_uniaxial_anis

        if self.cubic_anis:
            args = [
                "m_sat_mu0", "axis1_x", "axis1_y", "axis1_z", "axis2_x",
                "axis2_y", "axis2_z", "k1", "k2", "k3"
            ]
            c_cubic = nfem.site_wise_applicator(args,
                                                ccode_cubic,
                                                field_mwes=some_mwes)

            def calculate_cubic_anis():
                for ca in self.cubic_anis:
                    axis1, axis2, k1, k2, k3 = ca
                    axis1_x, axis1_y, axis1_z = axis1
                    axis2_x, axis2_y, axis2_z = axis2
                    args_values = [
                        self.m_sat_mu0, axis1_x, axis1_y, axis1_z, axis2_x,
                        axis2_y, axis2_z, k1, k2, k3
                    ]
                    c_cubic(args_values, fields=some_fields)

            self.calculate_cubic_anis = calculate_cubic_anis

        more_names = ["h_total", "h_ext", "h_demag", "h_exch"]
        more_mwes = self.mwe_list(more_names)
        more_fields = self.field_list(more_names)
        add_fields = nfem.site_wise_applicator([],
                                               ccode_add_fields,
                                               field_mwes=more_mwes)

        def add_ext_demag_exch():
            add_fields([], fields=more_fields)

        self.add_ext_demag_exch = add_ext_demag_exch

        if self.features["calculate_energy"]:
            swa_calculate_energy = \
             nfem.site_wise_applicator(["energy"], ccode_calculate_energy,
                                       field_mwes=[mwe_m],cofield_mwes=[mwe_h_total])
            cofield_h_total = nfem.field_to_cofield(field_h_total)

            def calculate_energy():
                nfem.field_to_cofield(field_h_total, target=cofield_h_total)
                energy = swa_calculate_energy([0.0],
                                              fields=[field_m],
                                              cofields=[cofield_h_total])
                return -self.m_sat_mu0 * energy[0]

            self.__calculate_energy = calculate_energy

        self.is_ready = True
Пример #12
0
print "Made MWEs"
sys.stdout.flush()


# Note that this magnetization is "mostly zero":
def fun_M0(dof_name_indices, position):
    if dof_name_indices[1][0] == 1:  # y-direction
        x = position[0]
        return 1.0 / (1.0 + (x * x / 4.0))
    else:
        return 0.0


# MMM

field_M2 = nfem.make_field(mwe_M2, fun_M0)

print "Made M2"
sys.stdout.flush()

diffop_m_m2 = nfem.diffop("<M(j) || M2(j)>, j:3")
prematrix_m_m2 = nfem.prematrix(diffop_m_m2, mwe_M, mwe_M2)

print "Made M2->M prematrix"
sys.stdout.flush()

m_m2 = nfem.prematrix_applicator(prematrix_m_m2)

field_M = nfem.cofield_to_field(m_m2(field_M2))

print "Have field_M"
Пример #13
0
                                 ignore_jumps=False)
prematrix_grad_phi = nfem.prematrix(diffop_grad_phi, mwe_H, mwe_phi_M)

log.info("OK 3!")

solve_bem = nfem.laplace_solver_bem(prematrix_laplace, inside_regions=[1])

log.info("OK 4!")

compute_div_M = nfem.prematrix_applicator(prematrix_div_M,
                                          interface_coeffs=[(1, -1, 1.0)])
compute_grad_phi = nfem.prematrix_applicator(prematrix_grad_phi)

log.info("OK 5!")

field_M0 = nfem.make_field(mwe_M, fun_M0)

cofield_div_M = compute_div_M(field_M0)

# DDD
ddd_field_div_M = nfem.cofield_to_field(cofield_div_M)
print "DDD div M: ", nfem.probe_field(
    ddd_field_div_M, [2.7, 0.2, 0.0])  # we may add: ,name_stem="rho_M")
# END DDD

field_phi_M = solve_bem(cofield_div_M)

log.info("OK 6!")
field_H = nfem.cofield_to_field(compute_grad_phi(field_phi_M))

log.info("OK 7!")