cvode.CVodeMalloc(cvode_mem, f, t.value, c, cvode.CV_SS, RTOL, ATOL) cvode.CVSpgmr(cvode_mem, jpre, MAXL) cvode.CVSpilsSetGSType(cvode_mem, gstype) cvode.CVSpilsSetDelt(cvode_mem, DELT) cvode.CVSpilsSetPreconditioner(cvode_mem, Precond, PSolve, ctypes.pointer(wdata)) PrintAllSpecies(c, ns, mxns, t) else: cvode.CVodeReInit(cvode_mem, f, t.value, c, cvode.CV_SS, RTOL, ATOL) cvode.CVSpilsSetPrecType(cvode_mem, jpre) cvode.CVSpilsSetGSType(cvode_mem, gstype) tout = T1 iout = 1 while iout <= NOUT: cvode.CVode(cvode_mem, tout, c, ctypes.byref(t), cvode.CV_NORMAL) PrintOutput(cvode_mem, t) if firstrun and iout % 3 == 0: PrintAllSpecies(c, ns, mxns, t) if tout > 0.9: tout += DTOUT else: tout *= TOUT_MULT iout += 1 PrintFinalStats(cvode_mem) for i in range(wdata.ngrp): cvode.denfree(wdata.P[i]) cvode.denfreepiv(wdata.pivot[i])
data.vdco = (1.0/(data.dy**2))*KV0 pdata = ctypes.pointer(data) SetInitialProfiles(u, data.dx, data.dy) abstol= cvode.realtype(1.0e-5*100) reltol= cvode.realtype(1.0e-5) cvode_mem = cvode.CVodeCreate(cvode.CV_BDF, cvode.CV_NEWTON) cvode.CVodeSetFdata(cvode_mem, ctypes.pointer(data)) cvode.CVodeMalloc(cvode_mem, f, T0, u, cvode.CV_SS, reltol, abstol) cvode.CVSpgmr(cvode_mem, cvode.PREC_LEFT, 0) cvode.CVSpilsSetGSType(cvode_mem, cvode.MODIFIED_GS) cvode.CVSpilsSetPreconditioner(cvode_mem, Precond, PSolve, pdata) print " \n2-species diurnal advection-diffusion problem\n" iout = 1 tout = TWOHR while iout <= NOUT: cvode.CVode(cvode_mem, tout, u, ctypes.byref(t), cvode.CV_NORMAL) PrintOutput(cvode_mem, u, t) iout += 1 tout += TWOHR PrintFinalStats(cvode_mem) for jx in range(MX): for jy in range(MY): cvode.denfree(data.P[jx][jy]) cvode.denfree(data.Jbd[jx][jy]) cvode.denfreepiv(data.pivot[jx][jy])