Skip to content

Commit

Permalink
make atol and rtol modifiable for users
Browse files Browse the repository at this point in the history
  • Loading branch information
KEHANG committed Feb 10, 2017
1 parent cea23a6 commit fcc05ec
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pychemkin/chemkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def postprocess(self, sens=False, rop=False, all=False, transpose=True):
def writeInputHomogeneousBatch(self,problemType, reactants, temperature, pressure, endTime,
Continuations=False, typeContinuation = None, Tlist = [], Plist = [],
variableVolume=False, variableVolumeProfile = None,
solverTimeStepProfile = None, sensitivity=[], rop=[]):
solverTimeStepProfile = None, sensitivity=[], rop=[],
atol=1e-20, rtol=1e-8):
"""
Write input file for homogeneous batch reactor
"""
Expand Down Expand Up @@ -260,10 +261,10 @@ def writeInputHomogeneousBatch(self,problemType, reactants, temperature, pressur
ADAP ! Save Additional Adaptive Points
ASTEPS 20 ! Use Solver Integration Steps
ATLS 1.0E-6 ! Sensitivity Absolute Tolerance
ATOL 1.0E-20 ! Absolute Tolerance
ATOL {0} ! Absolute Tolerance
MAXIT 4 ! Maximum Number of Iterations
RTLS 0.0001 ! Sensitivity Relative Tolerance
RTOL 1.0E-8 ! Relative Tolerance""")
RTOL {1} ! Relative Tolerance""".format(atol, rtol))

if solverTimeStepProfile:
with open(solverTimeStepProfile, 'rb') as csvfile2:
Expand Down Expand Up @@ -321,7 +322,8 @@ def writeInputHomogeneousBatch(self,problemType, reactants, temperature, pressur
def writeInputPlugFlow(self,problemType, reactants,
startingAxialPosition, endingAxialPosition, diameter, momentum=True, massflowrate = None, sccmflowrate = None,
temperature = None, pressure = None,
temperatureProfile = None, pressureProfile = None, sensitivity=[], rop=[]):
temperatureProfile = None, pressureProfile = None, sensitivity=[], rop=[],
atol=1e-9, rtol=1e-6):

"""
Write input file for typical plug flow
Expand Down Expand Up @@ -427,14 +429,14 @@ def writeInputPlugFlow(self,problemType, reactants,
ACHG 0.0 ! Maximum Absolute Change in Site Fractions
ADAP ! Save Additional Adaptive Points
ATLS 1.0E-6 ! Sensitivity Absolute Tolerance
ATOL 1.0E-9 ! Absolute Tolerance
ATOL {0} ! Absolute Tolerance
MAXIT 4 ! Maximum Number of Iterations
NNEG ! Force Non-negative Solution
PSV 1.0E-8 ! Scaling Factor for Relaxing Surface Equations (cm/sec)
RCHG 1.0E-6 ! Maximum Relative Change in Site Fractions
RTLS 0.0001 ! Sensitivity Relative Tolerance
RTOL 1.0E-6 ! Relative Tolerance
TSTP 1.0 ! Initial Integration Step (cm""")
RTOL {1} ! Relative Tolerance
TSTP 1.0 ! Initial Integration Step (cm""".format(atol, rtol))

input_stream+=("""
!
Expand Down

0 comments on commit fcc05ec

Please sign in to comment.