Esempio n. 1
0
    # field_J. We just overwrite field_sigma:
    #
    recompute_conductivity=nfem.site_wise_applicator(parameter_names=["H_x","H_y","sigma0","alpha"],
                                                      # all the names of extra parameters
                                                      code=code_recompute_conductivity,
                                                      fields=[the_field_sigma,field_J]
                                                      )
    #
    #
    recompute_conductivity([h_x,h_y,sigma0,alpha])
    return the_field_sigma


for i in range(1,2): # was: range(1,5)
    update_sigma(field_sigma)
    print "Iteration ",i," sigma at origin: ",nfem.probe_field(field_sigma,"sigma",[0.0,0.0])

print "Current: ",compute_total_current(field_sigma)

# alpha=0.0 gives:
# Current:  [-2.1286600897326298, 2.1287795081759233, 0.00049051004766091947, -0.00060992849094183171]

# alpha=0.01 gives:
# Current:  [-2.1372565971106514, 2.1374255105251221, 0.00049090636267681582, -0.00065981977713238163]

# alpha=0.02 gives:
# Current:  [-2.1458358123576202, 2.1460278219069608, 0.00049036037642959758, -0.00068236992575891153]

# 0.03
# Current:  [-2.1543906848336887, 2.1545946337056732, 0.00048908778486788556, -0.0006930366568447463]
Esempio n. 2
0
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:

direct_summer = ocaml.dipole_field_direct_summer(1, # nr cpus (processes to fork to)
                                                 0.0, # minimal distance
                                                 mwe_H,
                                                 mwe_M,
                                                 "H","M")
Esempio n. 3
0
# 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]

#for i in range(0,range_i):
#    pos=[-4.5+9.0*i/(0.0+range_i),0.0,0.0]
#    print pos, "=> ", nfem.probe_field(field_H,"H",pos)
Esempio n. 4
0
# 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]


#for i in range(0,range_i):
#    pos=[-4.5+9.0*i/(0.0+range_i),0.0,0.0]
#    print pos, "=> ", nfem.probe_field(field_H,"H",pos)
Esempio n. 5
0
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,
                        color_scheme=[(-0.3,[0.1,0.1,1.0]),
                                      (0.0,[0.1,1.0,0.1]),
                                      (0.3,[1.0,0.1,0.1])])

nfem.plot_scalar_field(nfem.cofield_to_field(cofield2d_div_M),
                        "rho_M","/tmp/plot-rho-M.ps",
                        plot_edges=False,
                        color_scheme=[(-2.0,[0.1,0.1,1.0]),
                                      (0.0,[0.1,1.0,0.1]),
                                      (2.0,[1.0,0.1,0.1])])
Esempio n. 6
0
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:

direct_summer = ocaml.dipole_field_direct_summer(
    1,  # nr cpus (processes to fork to)
    0.0,  # minimal distance
    mwe_H,
    mwe_M,