commands=[ # Note that this Jacobian actually does not # depend on laplace_phi, # so we need not make sure it is up-to-date. # Nevertheless, we have to provide it. ["JPLAN", "jacobian", ["v_phi", "v_laplace_phi"]] ]), ]) print "*** LAM ***", lam sys.stdout.flush() (cvode,fun_timings)=ocaml.raw_make_linalg_machine_cvode(\ lam, field_phi0, "jacobian","execute_jplan", "rhs", # True, # same_nonzero_pattern for jacobian False, # same_nonzero_pattern for jacobian # Why doesn't "true" work here?!?? 2, # max_order 10, # krylov_max ) def print_field(field, name="phi", t=None): for pos in range(0, 11): probed = ocaml.probe_field(field, name, [float(pos)]) print "T=%10s POS: %5.2f VAL: %s" % (str(t), pos, probed) print "*** CVODE ***", cvode sys.stdout.flush()
# Nevertheless, we have to provide it. ["JPLAN", "jacobian", ["v_phi", "v_laplace_phi"]] ], ), ], ) print "*** LAM ***", lam sys.stdout.flush() (cvode, fun_timings) = ocaml.raw_make_linalg_machine_cvode( lam, field_phi0, "jacobian", "execute_jplan", "rhs", # True, # same_nonzero_pattern for jacobian False, # same_nonzero_pattern for jacobian # Why doesn't "true" work here?!?? 2, # max_order 10, # krylov_max ) def print_field(field, name="phi", t=None): for pos in range(0, 11): probed = ocaml.probe_field(field, name, [float(pos)]) print "T=%10s POS: %5.2f VAL: %s" % (str(t), pos, probed) print "*** CVODE ***", cvode sys.stdout.flush()
) (mwe_T, field_T) = master_mwes_and_fields_by_name['T'] sundialsbuffer_initial = ocaml.raw_make_field(mwe_T, [], "", "sundials_initial") sundialsbuffer_final = ocaml.raw_make_field(mwe_T, [], "", "sundials_final") sundialsbuffer_starting = ocaml.raw_make_field(mwe_T, [], "", "sundials_work") ocaml.field_copy_into(field_T, sundialsbuffer_initial) ocaml.field_copy_into(field_T, sundialsbuffer_starting) (cvode,fun_timings)=ocaml.raw_make_linalg_machine_cvode(\ lam, sundialsbuffer_starting, "jacobian","execute_jplan", "rhs", jacobi_same_nonzero_pattern, max_order, krylov_max, ) heatingTime = SI(2e-9, 's') coolingTime = 0 * SI(10e-9, 's') timeStep = SI(0.025e-9, 's') timeStep = SI(0.1e-9, 's') heating_time = su.of(heatingTime) cooling_time = su.of(coolingTime) time_step = su.of(timeStep) # Set the electrical contact potential to +/- Phi_ext at left and # right contact:
lam_program("execute_jplan", commands=[["GOSUB", "set_H_exch"], ["JPLAN","jacobian",["v_M","v_H_exch"]] ]), ] ) print "*** LAM ***",lam sys.stdout.flush() sys.exit(0) # DDD (cvode,fun_timings)=ocaml.raw_make_linalg_machine_cvode(\ lam, field_M0, "jacobian","execute_jplan", "rhs", True, # same_nonzero_pattern for jacobian 2, # max_order 300, # krylov_max ) def print_field(field,name="M",pos=[-4.0,1.0],t=None): probed=ocaml.probe_field(field,name,pos) v=probed[0][1] 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()
T_initial=su.of(T_initial), ) (mwe_T,field_T) = master_mwes_and_fields_by_name['T'] sundialsbuffer_initial = ocaml.raw_make_field(mwe_T,[],"","sundials_initial") sundialsbuffer_final = ocaml.raw_make_field(mwe_T,[],"","sundials_final") sundialsbuffer_starting = ocaml.raw_make_field(mwe_T,[],"","sundials_work") ocaml.field_copy_into(field_T, sundialsbuffer_initial) ocaml.field_copy_into(field_T, sundialsbuffer_starting) (cvode,fun_timings)=ocaml.raw_make_linalg_machine_cvode(\ lam, sundialsbuffer_starting, "jacobian","execute_jplan", "rhs", jacobi_same_nonzero_pattern, max_order, krylov_max, ) heatingTime = SI(2e-9,'s') coolingTime = SI(2e-9,'s') timeStep=SI(0.025e-9,'s') heating_time=su.of(heatingTime) cooling_time = su.of(coolingTime) time_step=su.of(timeStep) # Set the electrical contact potential to +/- Phi_ext at left and # right contact: