-
Notifications
You must be signed in to change notification settings - Fork 47
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
H2 effects on CH4 lifetime #758
base: dev-h2
Are you sure you want to change the base?
Changes from all commits
2203297
a46e14e
ec1511f
42479b7
8ed3f3e
95b3196
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,8 @@ class OHComponent : public IModelComponent { | |
double CNMVOC; // coefficent for NMVOC | ||
double CNOX; // coefficent for NOX | ||
double CCH4; // coefficent for CH4 | ||
unitval CH2; // coefficent for CH4 | ||
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. Do you mind correcting the spelling of "coefficient" here and in previous lines? |
||
|
||
|
||
// logger | ||
Logger logger; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,7 @@ CNOX=0.0042 ; coefficent for NOX | |
CCO=-0.000105 ; coefficent for CO | ||
CNMVOC=-0.000315 ; coefficent for NMVOC (non methane VOC) | ||
CCH4=-0.32 ; coefficent for CH4 | ||
CH2=-0.00044625 ; coefficent for H2 | ||
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. Same spelling note; also, is there a reference/source for this value? If so please note it. 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. Was there some derivation needed for this, or was this coefficient in the right format from the original source? (And how similar were the coefficients for other emissions to the ones we are using now?) |
||
|
||
;------------------------------------------------------------------------ | ||
[ozone] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,12 +57,15 @@ void OHComponent::init(Core *coreptr) { | |
|
||
// Inform core what data we can provide | ||
core->registerCapability(D_LIFETIME_OH, getComponentName()); | ||
core->registerCapability(D_COEFFICENT_H2, getComponentName()); | ||
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. D_COEFFICIENT_H2 |
||
// Register inputs accepted. Note that more than one component | ||
// can accept an input | ||
core->registerInput(D_EMISSIONS_CO, getComponentName()); | ||
core->registerInput(D_EMISSIONS_NMVOC, getComponentName()); | ||
core->registerInput(D_EMISSIONS_NOX, getComponentName()); | ||
core->registerInput(D_EMISSIONS_H2, getComponentName()); | ||
core->registerInput(D_COEFFICENT_H2, getComponentName()); | ||
|
||
|
||
} | ||
|
||
|
@@ -100,8 +103,8 @@ void OHComponent::setData(const string &varName, const message_data &data) { | |
H_ASSERT(data.date != Core::undefinedIndex(), "date required"); | ||
NMVOC_emissions.set(data.date, data.getUnitval(U_TG_NMVOC)); | ||
} else if (varName == D_EMISSIONS_H2) { | ||
H_ASSERT(data.date != Core::undefinedIndex(), "date required"); | ||
H2_emissions.set(data.date, data.getUnitval(U_TG_H2)); | ||
H_ASSERT(data.date != Core::undefinedIndex(), "date required"); | ||
H2_emissions.set(data.date, data.getUnitval(U_TG_H2)); | ||
} else if (varName == D_INITIAL_LIFETIME_OH) { | ||
H_ASSERT(data.date == Core::undefinedIndex(), "date not allowed"); | ||
TOH0 = data.getUnitval(U_YRS); | ||
|
@@ -117,6 +120,9 @@ void OHComponent::setData(const string &varName, const message_data &data) { | |
} else if (varName == D_COEFFICENT_NOX) { | ||
H_ASSERT(data.date == Core::undefinedIndex(), "date not allowed"); | ||
CNOX = data.getUnitval(U_UNDEFINED); | ||
} else if (varName == D_COEFFICENT_H2) { | ||
H_ASSERT(data.date == Core::undefinedIndex(), "date not allowed"); | ||
CH2 = data.getUnitval(U_UNDEFINED); | ||
} else { | ||
H_THROW("Unknown variable name while parsing " + getComponentName() + | ||
": " + varName); | ||
|
@@ -149,6 +155,8 @@ void OHComponent::run(const double runToDate) { | |
unitval current_nox = NOX_emissions.get(runToDate); | ||
unitval current_co = CO_emissions.get(runToDate); | ||
unitval current_nmvoc = NMVOC_emissions.get(runToDate); | ||
unitval current_h2 = H2_emissions.get(runToDate); | ||
|
||
|
||
// get this from CH4 component, this is last year's value | ||
const double previous_ch4 = | ||
|
@@ -169,7 +177,13 @@ void OHComponent::run(const double runToDate) { | |
CNMVOC * | ||
((1.0 * +current_nmvoc) - | ||
NMVOC_emissions.get(NMVOC_emissions.firstdate()).value(U_TG_NMVOC)); | ||
toh = a + b + c + d; | ||
const double f = | ||
CH2 * | ||
((1.0 * +current_h2) - | ||
H2_emissions.get(H2_emissions.firstdate()).value(U_TG_H2)); | ||
|
||
|
||
toh = a + b + c + d + f; | ||
H_LOG(logger, Logger::DEBUG) | ||
<< "Year " << runToDate << " toh = " << toh << std::endl; | ||
} | ||
|
@@ -201,9 +215,12 @@ unitval OHComponent::getData(const std::string &varName, const double date) { | |
H_ASSERT(date != Core::undefinedIndex(), | ||
"Date required for NMVOC emissions"); | ||
returnval = NMVOC_emissions.get(date); | ||
} else if (varName == D_COEFFICENT_H2) { | ||
H_ASSERT(date == Core::undefinedIndex(), "Date not allowed for H2 coefficent"); | ||
returnval = CH2 ; | ||
} else if (varName == D_EMISSIONS_H2) { | ||
H_ASSERT(date != Core::undefinedIndex(), "Date required for H2 emissions"); | ||
returnval = H2_emissions.get(date); | ||
H_ASSERT(date != Core::undefinedIndex(), "Date required for H2 emissions"); | ||
returnval = H2_emissions.get(date); | ||
} else { | ||
H_THROW("Caller is requesting unknown variable: " + varName); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,9 @@ test_that("tau ", { | |
|
||
test_that("H2 emissions ", { | ||
|
||
# Check to make sure that can fetch and set the H2 emissions although | ||
# at this point changing the emissions will have no impact on | ||
# [ch4] dynamics but in the future it should... | ||
# Check to make sure that can fetch and set the H2 emissions and | ||
# that the effects of adding some H2 emissions change thigns | ||
# now that we have the CH4 indrect effects implement. | ||
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. # that the effects of adding some H2 emissions change things
# now that we have the CH4 indirect effects implemented |
||
|
||
hc <- newcore(ini) | ||
run(hc) | ||
|
@@ -45,12 +45,13 @@ test_that("H2 emissions ", { | |
|
||
diff <- abs(out$value - out2$value) | ||
|
||
# As of now the [CH4] and tau oh should not change | ||
expect_equal(mean(diff[out$variable == CONCENTRATIONS_CH4()]), 0) | ||
expect_equal(mean(diff[out$variable == LIFETIME_OH()]), 0) | ||
# Now we do expect to see changes in CH4 concentrations in response | ||
# to H2 emissions | ||
expect_gt(mean(diff[out$variable == CONCENTRATIONS_CH4()]), 0) | ||
expect_gt(mean(diff[out$variable == LIFETIME_OH()]), 0) | ||
|
||
# But if we can change the H2 emissions we should see a difference in | ||
# H2 emissions between the two new runs! | ||
# Since we are working off of some default H2 emissions = 0, then | ||
# changing the H2 emissions we should see a difference. | ||
expect_equal(mean(diff[out$variable == EMISSIONS_H2()]), new_val) | ||
|
||
}) | ||
|
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.
?