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])]) # End DDDDDD # we still have to correct the Z-field component. For now, we do this # with a site-wise applicator...
#print "field_J contents:", nfem.data_doftypes(field_J) # XXX NOTE: we should be able to make an applicator that does the # cofield_to_field conversion automatically! # # # Next, let us compute the new condictivity by site-wise operation on # field_J. We just overwrite field_sigma: # recompute_conductivity([h_x,h_y,sigma0,alpha],fields=[the_field_sigma,field_J]) print "Refcount field_sigma:",ocaml.sys_refcount(the_field_sigma) return the_field_sigma for i in range(1,5): # was: range(1,5) update_sigma(field_sigma,i) print "Forcing ocaml GC!" sys.stdout.flush() ocaml.sys_check_heap() print "Iteration ",i," sigma at origin: ",nfem.probe_field(field_sigma,[0.0,0.0]) print "Current: ",compute_total_current(field_sigma) # nfem.field_print_contents( field_sigma) print "field_sigma contents:", nfem.data_doftypes(field_sigma) nfem.plot_scalar_field(field_sigma,"sigma","/tmp/sigma.ps", color_scheme=[(0.9,[0.2,0.2,1.0]),(1.0,[0.2,1.0,0.2]),(1.1,[1.0,1.0,0.2])])
dbc_values=laplace_dbc_values) nfem.plot_scalar_field(field_phi, "phi","/tmp/plot-phi.ps", plot_edges=False, color_scheme=[(-1.2,[0.1,0.1,0.1]), (-1.1,[0.9,0.9,0.9]), (-1.0,[0.1,0.1,0.1]), (-0.9,[0.9,0.9,0.9]), (-0.8,[0.1,0.1,0.1]), (-0.7,[0.9,0.9,0.9]), (-0.6,[0.1,0.1,0.1]), (-0.5,[0.9,0.9,0.9]), (-0.4,[0.1,0.1,0.1]), (-0.3,[0.9,0.9,0.9]), (-0.2,[0.1,0.1,0.1]), (-0.1,[0.9,0.9,0.9]), (0.0,[0.1,0.1,0.1]), (0.1,[0.9,0.9,0.9]), (0.2,[0.1,0.1,0.1]), (0.3,[0.9,0.9,0.9]), (0.4,[0.1,0.1,0.1]), (0.5,[0.9,0.9,0.9]), (0.6,[0.1,0.1,0.1]), (0.7,[0.9,0.9,0.9]), (0.8,[0.1,0.1,0.1]), (0.9,[0.9,0.9,0.9]), (1.0,[0.1,0.1,0.1]), (1.1,[0.9,0.9,0.9])]) cofield_div_J =compute_laplace(field_phi)
laplace_solver=nfem.laplace_solver(prematrix_laplace, dirichlet_bcs=[(-1,1,laplace_dbc)], mwe_mid=field_sigma) field_phi = laplace_solver(cofield_drho_by_dt, dbc_values=laplace_dbc_values) field_J = nfem.cofield_to_field(compute_J(field_phi)) print "Total current: ",compute_total_current(field_J) nfem.plot_scalar_field(nfem.cofield_to_field(_cofield_div_J), "drho_by_dt","/tmp/plot-div-j.ps", color_scheme=[(-2.0,[0.2,0.2,1.0]), (-0.2,[0.2,1.0,1.0]), (0.0,[0.4,0.4,0.4]), (0.2,[1.0,1.0,0.0]), (2.0,[1.0,0.2,0.2])]); # # Results from a timed test run with cached mesh # # element order=1 # =============== # # Iteration 1 sigma at origin: 1.00359354396 # Iteration 2 sigma at origin: 1.00361510401 # Iteration 3 sigma at origin: 1.00361511452 # Iteration 4 sigma at origin: 1.00361511457
field_phi = laplace_solver(cofield_drho_by_dt, dbc_values=laplace_dbc_values) nfem.plot_scalar_field(field_phi, "phi", "/tmp/plot-phi.ps", plot_edges=False, color_scheme=[(-1.2, [0.1, 0.1, 0.1]), (-1.1, [0.9, 0.9, 0.9]), (-1.0, [0.1, 0.1, 0.1]), (-0.9, [0.9, 0.9, 0.9]), (-0.8, [0.1, 0.1, 0.1]), (-0.7, [0.9, 0.9, 0.9]), (-0.6, [0.1, 0.1, 0.1]), (-0.5, [0.9, 0.9, 0.9]), (-0.4, [0.1, 0.1, 0.1]), (-0.3, [0.9, 0.9, 0.9]), (-0.2, [0.1, 0.1, 0.1]), (-0.1, [0.9, 0.9, 0.9]), (0.0, [0.1, 0.1, 0.1]), (0.1, [0.9, 0.9, 0.9]), (0.2, [0.1, 0.1, 0.1]), (0.3, [0.9, 0.9, 0.9]), (0.4, [0.1, 0.1, 0.1]), (0.5, [0.9, 0.9, 0.9]), (0.6, [0.1, 0.1, 0.1]), (0.7, [0.9, 0.9, 0.9]), (0.8, [0.1, 0.1, 0.1]), (0.9, [0.9, 0.9, 0.9]), (1.0, [0.1, 0.1, 0.1]), (1.1, [0.9, 0.9, 0.9])]) cofield_div_J = compute_laplace(field_phi)
# # Next, let us compute the new condictivity by site-wise operation on # field_J. We just overwrite field_sigma: # recompute_conductivity([h_x, h_y, sigma0, alpha], fields=[the_field_sigma, field_J]) print "Refcount field_sigma:", ocaml.sys_refcount(the_field_sigma) return the_field_sigma for i in range(1, 5): # was: range(1,5) update_sigma(field_sigma, i) print "Forcing ocaml GC!" sys.stdout.flush() ocaml.sys_check_heap() print "Iteration ", i, " sigma at origin: ", nfem.probe_field( field_sigma, [0.0, 0.0]) print "Current: ", compute_total_current(field_sigma) # nfem.field_print_contents( field_sigma) print "field_sigma contents:", nfem.data_doftypes(field_sigma) nfem.plot_scalar_field(field_sigma, "sigma", "/tmp/sigma.ps", color_scheme=[(0.9, [0.2, 0.2, 1.0]), (1.0, [0.2, 1.0, 0.2]), (1.1, [1.0, 1.0, 0.2])])