geoschem / geos-chem

GEOS-Chem "Science Codebase" repository. Contains GEOS-Chem science routines, run directory generation scripts, and interface code. This repository is used as a submodule within the GCClassic and GCHP wrappers, as well as in other modeling contexts (external ESMs).
http://geos-chem.org
Other
170 stars 166 forks source link

How to correctly add tags to custom.equ in KPP and run GEOS-Chem with custom mechanism? #2550

Open LittleFeify opened 2 weeks ago

LittleFeify commented 2 weeks ago

Your name

feify

Your affiliation

SUST

Please provide a clear and concise description of your question or discussion topic.

Hello, I am using GEOS-Chem-14.4.3 to track the budget for species such as NO, NO2, etc. I made changes to the custom.equ file and add the PNO, LNO2.. in custom.kpp as shown in the image below. But there are some errors when reading new files. So I'm wondering what the custom.equ file format looks like? Can I add a family including all species I want to track in custom.kpp, then I need to add the PNO to custom.equ again? Is there some more detailed manual or case on how to add tags, please. Thanks a lot.

custom_equ

custom_kpp

yantosca commented 2 weeks ago

Thanks for writing @LittleFeify. Would you be able to post the log file that shows the specific error that you are getting?

We do have a guide on adding prod/loss families to a mechanism on ReadTheDocs:

yantosca commented 2 weeks ago

Also the custom.eqn file is the same as the fullchem.eqn file out-of-the-box. We provide the custom.eqn file so that users can modify it without touching the fullchem.eqn file. That way if there is a problem, one can always start over by copying the fullchem.eqn to the custom.eqn.

LittleFeify commented 2 weeks ago

Hi,
Thanks for your reply. I've resolved the last question by updating the Unix text format and need to add several species tags in custom.equ for NOx tracking. This might create issues in custom.kpp due to the large number of families. The kpp compile succeeded after I deleted some families, so how many families can we add? Should I add the tagged species individually to custom.kpp to account for every reaction contribution?

The tags like the below in custom.eqn

HNO3 + hv = PNO2_1538 + LHNO3_1538 + OH + NO2 :                                     PHOTOL(16);
HNO2 + hv = PNO_1539 + LHNO2_1539 + OH + NO :                                      PHOTOL(15);
HNO4 + hv = OH + NO3 :                       PHOTOL(17);
HNO4 + hv = PNO2_1541 + HO2 + NO2 :          PHOTOL(18);
NO3 + hv = PNO2_1542 + NO2 + O :             PHOTOL(12);     {2014/02/03; Eastham2014; SDE}
NO3 + hv = PNO_1543 + NO + O2 :

...... The added families are like below in custom.kpp:

PNO2_521 : NO2;
LNO_522 : NO;
LNO_523 : NO;
PNO2_523 : NO2;

.....

The error occurred while running ./build_mechanism.sh.
KPP is parsing the equation file.Warning :gckpp.kpp:227:    Unnecessary ';'
Error : Too many families.

Looking forward to your reply. Thanks!

yantosca commented 1 week ago

Thanks for writing @LittleFeify. KPP 3.1.1 allows for 300 family species. To increase the limit, go to KPP/src/gdata.h and change the MAX_FAMILIES constant in this section of code:

https://github.com/KineticPreProcessor/KPP/blob/cd03fe0adcde0cce76498981812cd302959185c2/src/gdata.h#L42-L81

Then recompile KPP:

$ cd KPP/src
$ make distclean
$ make -j

Then rebuild the GEOS-Chem fullchem mechanism as usual. That should fix it.

LittleFeify commented 1 week ago

Thanks, Bob. I fixed the last issue by modifying the gdata.h file but encountered a new error while running GEOS-Chem. The restart file needs all variables that I added in custom.equ and the families in custom.kpp. So I need to add hundreds of variables in my case, is that right? I created those dummy variables in the restart file, and an error occurred.I uploaded my GC.log. [GC.log](https://github.com/user-attachments/files/17688452/GC.log

GEOS-Chem ERROR: KPP failed to converge after 2 iterations! -> at Do_FullChem (in module GeosCore/FullChem_mod.F90)

GEOS-Chem ERROR: Error encountered in "Do_FullChem"! -> at Do_Chemistry (in module GeosCore/chemistry_mod.F90)

GEOS-CHEM ERROR: Error encountered in "Do_Chemistry"! STOP at -> at GEOS-Chem (in GeosCore/main.F90)

I am not sure whether other people have met a similar problem. Looking forward to your reply. Many thanks!