if t!=None: print "%8.6f %8.6f %8.6f %8.6f" % (t,v[0],v[1],v[2]) else: print "%8.6f %8.6f %8.6f" % (v[0],v[1],v[2]) print "*** CVODE ***",cvode sys.stdout.flush() print_field(field_M0,t=0.0) for tt in range(1,100): target_time=tt*0.01 ocaml.raw_cvode_advance(cvode,field_M,target_time,-1) print_field(field_M,t=target_time) ocaml.linalg_machine_get_field(lam,field_H_exch,"v_H_exch") ocaml.linalg_machine_get_field(lam,field_M,"v_M") nfem.visual.fields2vtkfile([field_M,field_H_exch],'05_h_periodic_%03d.vtk' % tt, mesh) """ H_exch operator matrix for simple2d.nmesh: DDD OP-MX 'op_H_exch' (non-periodic): [|[|-10.3125; 0.; 0.; 9.0625; 0.; 0.; 1.25; 0.; 0.; -15.625; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.|]; [|0.; -10.3125; 0.; 0.; 9.0625; 0.; 0.; 1.25; 0.; 0.; -15.625; 0.; 0.; 0.; 0.; 0.; 0.; 0.|]; [|0.; 0.; -10.3125; 0.; 0.; 9.0625; 0.; 0.; 1.25; 0.; 0.; -15.625; 0.; 0.; 0.; 0.; 0.; 0.|]; [|9.0625; 0.; 0.; -10.3125; 0.; 0.; 0.; 0.; 0.; 16.875; 0.; 0.; 0.; 0.; 0.; 0.; 0.; 0.|]; [|0.; 9.0625; 0.; 0.; -10.3125; 0.; 0.; 0.; 0.; 0.; 16.875; 0.; 0.; 0.; 0.; 0.; 0.; 0.|];
#ocaml.linalg_machine_set_iparam(lam,"Phi_ext",5.0*100*1e12) voltage = SI(0.2186, "V") #Need factor three for new geometry voltage = SI(0.218353, "V") #Need factor three for new geometry print "Setting voltage to", voltage ocaml.linalg_machine_set_iparam(lam, "Phi_ext", su.of(voltage)) for i in range(int(heating_time // time_step) + 1): ocaml.raw_cvode_advance(cvode, sundialsbuffer_final, float(i * time_step), max_it) for name in master_mwes_and_fields_by_name.keys(): (mwe, field) = master_mwes_and_fields_by_name[name] ocaml.linalg_machine_get_field(lam, field, "v_%s" % name) fields = map(lambda a: a[1], master_mwes_and_fields_by_name.values()) #nfem.visual.fields2vtkfile(fields,'H-%02d.vtk' % i,my_mesh,format='binary') last_i = i j0 = numpy.array( ocaml.probe_field(master_mwes_and_fields_by_name['j'][1], 'j', [0., 0., 0.])[0][1]) j1 = numpy.array( ocaml.probe_field(master_mwes_and_fields_by_name['j'][1], 'j', [-499., 0., 0.])[0][1]) print "j0 in A/m^2:", j0 * su.conversion_factor_of(SI("A/m^2")) print "j1 in A/m^2:", j1 * su.conversion_factor_of(SI("A/m^2"))
print "Setting external potential" #ocaml.linalg_machine_set_iparam(lam,"Phi_ext",5.0*100*1e12) voltage = SI(0.2186,"V") #Need factor three for new geometry voltage = SI(0.218353,"V") #Need factor three for new geometry print "Setting voltage to",voltage ocaml.linalg_machine_set_iparam(lam,"Phi_ext",su.of(voltage)) for i in range(int(heating_time//time_step)+1): ocaml.raw_cvode_advance(cvode,sundialsbuffer_final,float(i*time_step),max_it) for name in master_mwes_and_fields_by_name.keys(): (mwe,field)=master_mwes_and_fields_by_name[name] ocaml.linalg_machine_get_field(lam,field,"v_%s" % name) fields = map( lambda a: a[1],master_mwes_and_fields_by_name.values()) nfem.visual.fields2vtkfile(fields,'H-%02d.vtk' % i,my_mesh,format='binary') last_i = i j0 = numpy.array(ocaml.probe_field(master_mwes_and_fields_by_name['j'][1],'j',[0.,0.,0.])[0][1]) j1 = numpy.array(ocaml.probe_field(master_mwes_and_fields_by_name['j'][1],'j',[-499.,0.,0.])[0][1]) print "j0 in A/m^2:",j0*su.conversion_factor_of(SI("A/m^2")) print "j1 in A/m^2:",j1*su.conversion_factor_of(SI("A/m^2")) T0 = ocaml.probe_field(sundialsbuffer_final,"T",[0.0, 0.0, 0.0])[0][1] T1 = ocaml.probe_field(sundialsbuffer_final,"T",[-499.0, 0.0, 0.0])[0][1] T2 = ocaml.probe_field(sundialsbuffer_final,"T",[-25.0, 10.0, 10.0])[0][1]
time_step = 100 # Set the electrical contact potential to +/- Phi_ext at left and # right contact: ocaml.linalg_machine_set_iparam(lam, "Phi_ext", 5.0) ocaml.raw_cvode_advance(cvode, sundialsbuffer_final, heating_time, max_it) # Turn off electric heating: ocaml.linalg_machine_set_iparam(lam, "Phi_ext", 0.0) print "Known fieldnames are", master_mwes_and_fields_by_name.keys() fields = map(lambda a: a[0], master_mwes_and_fields_by_name.values()) for field in fields: print "known fields are", ocaml.sys_ocamlpill_type(field) #Thomas, we only have one filed in master_mwes and fields -- is that right?x for i in range(500): ocaml.raw_cvode_advance(cvode, sundialsbuffer_final, heating_time + i * time_step, max_it) (mwe, field) = master_mwes_and_fields_by_name['T'] ocaml.linalg_machine_get_field(lam, field, "v_T") #Thomas, do we need to copy the data back into master_mwes_and_fields_by_name? nfem.visual.fields2vtkfile(master_mwes_and_fields_by_name['T'][1], 'T-%04d.vtk' % i, my_mesh, format='binary') T0 = ocaml.probe_field(sundialsbuffer_final, "T", [0.0, 0.0, 0.0]) print "i: %3d T: %s" % (i, repr(T0))
) heating_time=0.5 time_step=100 # Set the electrical contact potential to +/- Phi_ext at left and # right contact: ocaml.linalg_machine_set_iparam(lam,"Phi_ext",5.0) ocaml.raw_cvode_advance(cvode,sundialsbuffer_final,heating_time,max_it) # Turn off electric heating: ocaml.linalg_machine_set_iparam(lam,"Phi_ext",0.0) print "Known fieldnames are",master_mwes_and_fields_by_name.keys() fields = map( lambda a: a[0],master_mwes_and_fields_by_name.values()) for field in fields: print "known fields are",ocaml.sys_ocamlpill_type(field) #Thomas, we only have one filed in master_mwes and fields -- is that right?x for i in range(500): ocaml.raw_cvode_advance(cvode,sundialsbuffer_final,heating_time+i*time_step,max_it) (mwe,field)=master_mwes_and_fields_by_name['T'] ocaml.linalg_machine_get_field(lam,field,"v_T") #Thomas, do we need to copy the data back into master_mwes_and_fields_by_name? nfem.visual.fields2vtkfile(master_mwes_and_fields_by_name['T'][1],'T-%04d.vtk' % i,my_mesh,format='binary') T0 = ocaml.probe_field(sundialsbuffer_final,"T",[0.0, 0.0, 0.0]) print "i: %3d T: %s" % (i,repr(T0))