AtChem / AtChem2

Atmospheric chemistry box-model for the MCM
MIT License
59 stars 22 forks source link

Species Constraints #470

Closed morshedahmed17 closed 2 years ago

morshedahmed17 commented 2 years ago

Hello,

I was playing around with the species constraints file. I am running the test model and created a dummy O3 constrained file. However, when I run the model I am getting some errors. Please see the attached. error_contraints

spco commented 2 years ago

This error usually occurs when the global time goes beyond the last datapoint in a constraint file. At a guess, does your O3 constraint file have a final datapoint somewhere in the time range 41400-42300? Or possibly 42300-43200? If so, this error should disappear if you supply an O3 constraint covering the full time range up to 43200.

morshedahmed17 commented 2 years ago

I supply the same timestamp as the test case. Please see the attached.

error_constraints_1

spco commented 2 years ago

Ah, reading more closely, the time of the the interpolated data is 4.3275e+04 = 43275. Please be aware that the underlying ODE solver we use (CVODE from Sundials) does not always respect the final timestep in the simulation. Rather, it chooses the timesteps to use to best solve the ODE, and then, if the timestep it uses is beyond the final timestep required, it interpolates it backwards in time.

In practise, what this means is that you may need to supply a datapoint a little beyond the final timestep of the simulation, for the ODE solver to make use of (otherwise we get this error). Happily, in your case this looks like 8.0e+11 at 43300 will suffice?

morshedahmed17 commented 2 years ago

Thanks a lot. It worked.

Can you also let me know why there is that error named "No. error test failures =57" in the attached.

Also is it possible to get the data from a published paper to understand the output files properly?

error2

spco commented 2 years ago

In most cases you don't worry about the No. error test failures count - this is exposing some of the statistics from the CVODE ODE solver - please see https://sundials.readthedocs.io/en/latest/cvode/Usage/index.html#c.CVodeSetMaxErrTestFails for the documentation. In this case "error test" is a technical term in solving ordinary differential equations, and should not be interpreted as an error in the program.

The best documentation for the output files can be found in the manual, at https://github.com/AtChem/AtChem2/blob/master/doc/AtChem2-Manual.pdf . Hope that is sufficient for your needs?

morshedahmed17 commented 2 years ago

Thanks for your reply. I already read the manual.

Currently, I am using the mechanism file of phenol and trying to constrain the phenol concentration. However, getting the attached error. Does it mean that I can not constrain phenol as I am using its mechanism file?

image

spco commented 2 years ago

I'm not sure of the specifics of the problem (please supply the input files if you'd like me to have a look) but this error is normally raised when a species is constrained that doesn't occur in the mechanism file. Can you confirm that your mechanism file does have C6H6O in it, on the left-hand side of at least one reaction?

morshedahmed17 commented 2 years ago

This specie is on the left-hand side of many reactions. Previously, instead of using PHENOL, I was using C6H6O. However, I have edited the species name in speciesConstrained.config and also in constraints>species as "PHENOL" but still getting the same error.

mcm_subset_phenol.txt image

spco commented 2 years ago

Hmm, could you please confirm that PHENOL is present in the speciesConstrained.config file? And what is the directory in which the PHENOL , OH constraint files are held, and is this being correctly supplied to the --spec_constraints argument?

morshedahmed17 commented 2 years ago

Yes, PHENOL is present in the speciesConstrained.config file. You can see it in the attached figure. Also, you will find the --spec_constraints argument in the attached figure at the very end. The argument worked well with O3, NO, and OH.

image

rs028 commented 2 years ago

@morshedahmed17 do you have a file called PHENOL in the constraints/species/ directory? And did you download the Benzene mechanism from the MCM website?

morshedahmed17 commented 2 years ago

Yes. I do have a file called PHENOL in the constraints/species/ directory. I downloaded Phenol mechanism from MCM.

rs028 commented 2 years ago

Can you send the mechanism file?

morshedahmed17 commented 2 years ago

Here it is.

mcm_subset_phenol.txt

rs028 commented 2 years ago

I tried to compile this mechanism and I am getting the same error as reported in #471. It now occurs to me that we have seen it before and it is due to a mistake in the MCM database. See issue #451 and the solution indicated there.

morshedahmed17 commented 2 years ago

It worked. Thanks a lot!