Cantera 2.6.0
FalloffMgr.h
Go to the documentation of this file.
1/**
2 * @file FalloffMgr.h
3 *
4 * @deprecated Deprecated in Cantera 2.6 and removed thereafter. Replaced by
5 * FalloffRate objects managed by MultiRate evaluators.
6 */
7
8// This file is part of Cantera. See License.txt in the top-level directory or
9// at https://cantera.org/license.txt for license and copyright information.
10
11#ifndef CT_FALLOFFMGR_H
12#define CT_FALLOFFMGR_H
13
14#include "Falloff.h"
15#include "cantera/base/global.h"
16
17namespace Cantera
18{
19
20
21/**
22 * A falloff manager that implements any set of falloff functions.
23 * @ingroup falloffGroup
24 *
25 * @deprecated Deprecated in Cantera 2.6 and removed thereafter. Replaced by
26 * FalloffRate objects managed by MultiRate evaluators.
27 */
29{
30public:
31 //! Constructor.
33 m_worksize(0) {
34 }
35
36 //! Install a new falloff function calculator.
37 /*
38 * @param rxn Index of the falloff reaction. This will be used to
39 * determine which array entry is modified in method pr_to_falloff.
40 * @param reactionType Either `FALLOFF_RXN` or `CHEMACT_RXN`
41 * @param f The falloff function.
42 *
43 * @deprecated To be removed after Cantera 2.6.
44 */
45 void install(size_t rxn, int reactionType, shared_ptr<Falloff> f) {
46 warn_deprecated("FalloffMgr::install()",
47 "To be removed after Cantera 2.6. Specify reaction type using "
48 "string instead.");
49
50 m_rxn.push_back(rxn);
51 m_offset.push_back(m_worksize);
52 m_worksize += f->workSize();
53 m_falloff.push_back(f);
54 m_isfalloff.push_back(reactionType == FALLOFF_RXN);
55 m_indices[rxn] = m_falloff.size()-1;
56 }
57
58 //! Install a new falloff function calculator.
59 /*
60 * @param rxn Index of the falloff reaction. This will be used to
61 * determine which array entry is modified in method pr_to_falloff.
62 * @param type Reaction type identifier.
63 * @param f The falloff function.
64 */
65 void install(size_t rxn, std::string type, shared_ptr<Falloff> f) {
66 m_rxn.push_back(rxn);
67 m_offset.push_back(m_worksize);
68 m_worksize += f->workSize();
69 m_falloff.push_back(f);
70 m_isfalloff.push_back(type == "falloff-legacy");
71 m_indices[rxn] = m_falloff.size()-1;
72 }
73
74 /*!
75 * Replace an existing falloff function calculator
76 *
77 * @param rxn External reaction index
78 * @param f New falloff function, of the same kind as the existing one
79 */
80 void replace(size_t rxn, shared_ptr<Falloff> f) {
81 m_falloff[m_indices[rxn]] = f;
82 }
83
84 //! Size of the work array required to store intermediate results.
85 size_t workSize() {
86 return m_worksize;
87 }
88
89 /**
90 * Update the cached temperature-dependent intermediate
91 * results for all installed falloff functions.
92 * @param t Temperature [K].
93 * @param work Work array. Must be dimensioned at least workSize().
94 */
95 void updateTemp(doublereal t, doublereal* work) {
96 for (size_t i = 0; i < m_rxn.size(); i++) {
97 m_falloff[i]->updateTemp(t, work + m_offset[i]);
98 }
99 }
100
101 /**
102 * Given a vector of reduced pressures for each falloff reaction,
103 * replace each entry by the value of the falloff function.
104 */
105 void pr_to_falloff(doublereal* values, const doublereal* work) {
106 for (size_t i = 0; i < m_rxn.size(); i++) {
107 double pr = values[m_rxn[i]];
108 if (m_isfalloff[i]) {
109 // Pr / (1 + Pr) * F
110 values[m_rxn[i]] *=
111 m_falloff[i]->F(pr, work + m_offset[i]) / (1.0 + pr);
112 } else {
113 // 1 / (1 + Pr) * F
114 values[m_rxn[i]] =
115 m_falloff[i]->F(pr, work + m_offset[i]) / (1.0 + pr);
116 }
117 }
118 }
119
120protected:
121 std::vector<size_t> m_rxn;
122 std::vector<shared_ptr<Falloff> > m_falloff;
123 vector_int m_loc;
124 std::vector<vector_fp::difference_type> m_offset;
125 size_t m_worksize;
126
127 //! Distinguish between falloff and chemically activated reactions
128 std::vector<bool> m_isfalloff;
129
130 //! map of external reaction index to local index
131 std::map<size_t, size_t> m_indices;
132};
133}
134
135#endif
A falloff manager that implements any set of falloff functions.
Definition: FalloffMgr.h:29
size_t workSize()
Size of the work array required to store intermediate results.
Definition: FalloffMgr.h:85
void install(size_t rxn, std::string type, shared_ptr< Falloff > f)
Install a new falloff function calculator.
Definition: FalloffMgr.h:65
std::map< size_t, size_t > m_indices
map of external reaction index to local index
Definition: FalloffMgr.h:131
void pr_to_falloff(doublereal *values, const doublereal *work)
Given a vector of reduced pressures for each falloff reaction, replace each entry by the value of the...
Definition: FalloffMgr.h:105
FalloffMgr()
Constructor.
Definition: FalloffMgr.h:32
void install(size_t rxn, int reactionType, shared_ptr< Falloff > f)
Install a new falloff function calculator.
Definition: FalloffMgr.h:45
void replace(size_t rxn, shared_ptr< Falloff > f)
Definition: FalloffMgr.h:80
std::vector< bool > m_isfalloff
Distinguish between falloff and chemically activated reactions.
Definition: FalloffMgr.h:128
void updateTemp(doublereal t, doublereal *work)
Update the cached temperature-dependent intermediate results for all installed falloff functions.
Definition: FalloffMgr.h:95
This file contains definitions for utility functions and text for modules, inputfiles,...
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
void warn_deprecated(const std::string &source, const AnyBase &node, const std::string &message)
A deprecation warning for syntax in an input file.
Definition: AnyMap.cpp:1901
std::vector< int > vector_int
Vector of ints.
Definition: ct_defs.h:186
const int FALLOFF_RXN
The general form for a gas-phase association or dissociation reaction, with a pressure-dependent rate...
Definition: reaction_defs.h:46