-
Notifications
You must be signed in to change notification settings - Fork 250
SurfaceArrhenius <=> StickingCoefficient #2148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6c29e6f
added method to convert SurfaceaArrhenius to StickingCoeff
davidfarinajr 2efc4e5
make sure the kinetics types are all the same when averaging kinetics
davidfarinajr cb89d46
added method to convert StickingCoeff kinetics to SurfaceArrhenius
davidfarinajr bc78dbb
added reaction unit tests for converting sticking to SA and vice versa
davidfarinajr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -729,6 +729,103 @@ def get_surface_rate_coefficient(self, T, surface_site_density): | |
|
|
||
| raise NotImplementedError("Can't get_surface_rate_coefficient for kinetics type {!r}".format(type(self.kinetics))) | ||
|
|
||
| def surface_arrhenius_to_sticking_coeff(self, surface_site_density, Tmin=None, Tmax=None): | ||
| """ | ||
| Converts `SurfaceArrhenius` kinetics to `StickingCoeff` kinetics using the provided | ||
| `surface_site_density` in SI units (mol/m^2). The reaction's kinetics type must but be | ||
| `SurfaceArrhenius`. | ||
|
|
||
| Returns: | ||
| `StickingCoefficient` kinetics | ||
| """ | ||
| cython.declare(kf=StickingCoefficient) | ||
| cython.declare(sticking_coefficient=cython.double, molecular_weight_kg=cython.double) | ||
| cython.declare(Tlist=np.ndarray, klist=np.ndarray, i=cython.int, number_of_sites=cython.int) | ||
| if not isinstance(self.kinetics, SurfaceArrhenius): | ||
| raise TypeError(f'Expected a SurfaceArrhenius object but received {self.kinetics}') | ||
| # determine the adsorbate and number of surface sites | ||
| adsorbate = None | ||
| number_of_sites = 0 | ||
| for r in self.reactants: | ||
| if r.contains_surface_site(): | ||
| number_of_sites += 1 | ||
| else: | ||
| if adsorbate is None: | ||
| adsorbate = r | ||
| else: | ||
| logging.error("Error in kinetics for reaction {0!s}: " | ||
| "more than one adsorbate detected".format(self)) | ||
| raise ReactionError("More than one adsorbate detected") | ||
|
|
||
| if adsorbate is None or adsorbate.contains_surface_site(): | ||
| logging.error("Problem reaction: {0!s}".format(self)) | ||
| raise ReactionError("Couldn't find the adsorbate!") | ||
| molecular_weight_kg = adsorbate.molecular_weight.value_si | ||
|
|
||
| # generate temperature array to evaluate the rate coeff | ||
| if Tmin is not None and Tmax is not None: | ||
| Tlist = 1.0 / np.linspace(1.0 / Tmax.value, 1.0 / Tmin.value, 50) | ||
| else: | ||
| Tlist = 1.0 / np.arange(0.0005, 0.0034, 0.0001) | ||
|
|
||
| # Determine the values of the sticking coefficient at each temperature | ||
| klist = np.zeros_like(Tlist) | ||
| for i in range(len(Tlist)): | ||
| sticking_coefficient = self.kinetics.get_rate_coefficient(Tlist[i]) | ||
| sticking_coefficient /= math.sqrt(constants.kB * Tlist[i] / (2 * math.pi * molecular_weight_kg)) | ||
| klist[i] = sticking_coefficient | ||
| for i in range(number_of_sites): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpicky, but this could just be klist *= surface_site_density**number_of_sites. |
||
| klist *= surface_site_density | ||
|
|
||
| # set the max sticking coeff to 1 | ||
| for i in np.argwhere(klist>1): | ||
| klist[i] = 1 | ||
|
|
||
| # create Sticking Coeff kinetics and fit to sticking coeff array | ||
| kf = StickingCoefficient() | ||
| kf.fit_to_data(Tlist, klist, "", kf.T0.value_si) | ||
| return kf | ||
|
|
||
| def sticking_coeff_to_surface_arrhenius(self, surface_site_density, Tmin=None, Tmax=None): | ||
| """ | ||
| Converts `StickingCoefficient` kinetics to `SurfaceArrhenius` kinetics using the provided | ||
| `surface_site_density` in SI units (mol/m^2). The reaction's kinetics type must but be | ||
| `StickingCoefficent`. | ||
|
|
||
| Returns: | ||
| `SurfaceArrhenius` kinetics | ||
| """ | ||
| cython.declare(kf=SurfaceArrhenius) | ||
| cython.declare(Tlist=np.ndarray, klist=np.ndarray, i=cython.int) | ||
| if not isinstance(self.kinetics, StickingCoefficient): | ||
| raise TypeError(f'Expected a Sticking Coeff object but received {self.kinetics}') | ||
|
|
||
| # Get the units for the reverse rate coefficient | ||
| try: | ||
| surf_reacts = [spcs for spcs in self.reactants if spcs.contains_surface_site()] | ||
| except IndexError: | ||
| raise KineticsError("Species do not have an rmgpy.molecule.Molecule." | ||
| "Cannot determine units for rate coefficient.") | ||
| n_surf = len(surf_reacts) | ||
| n_gas = len(self.reactants) - len(surf_reacts) | ||
| kunits = get_rate_coefficient_units_from_reaction_order(n_gas, n_surf) | ||
|
|
||
| # generate temperature array to evaluate the rate coeff | ||
| if Tmin is not None and Tmax is not None: | ||
| Tlist = 1.0 / np.linspace(1.0 / Tmax.value, 1.0 / Tmin.value, 50) | ||
| else: | ||
| Tlist = 1.0 / np.arange(0.0005, 0.0034, 0.0001) | ||
|
|
||
| # Determine the values of the rate coeff k_f(T) at each temperature | ||
| klist = np.zeros_like(Tlist) | ||
| for i in range(len(Tlist)): | ||
| klist[i] = self.get_surface_rate_coefficient(Tlist[i], surface_site_density) | ||
|
|
||
| # create Surface Arrh kinetics and fit to rate coeff array | ||
| kf = SurfaceArrhenius() | ||
| kf.fit_to_data(Tlist, klist, kunits) | ||
| return kf | ||
|
|
||
| def fix_diffusion_limited_a_factor(self, T): | ||
| """ | ||
| Decrease the pre-exponential factor (A) by the diffusion factor | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpicky, but do we have adsorption reactions that have multiple adsorbates? I think this is really testing if the reaction is the correct type (i.e. adsorption). maybe the text could say "multiple adsorbates detected, reaction probably isn't adsorption"?