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
169 stars 165 forks source link

[QUESTION] How to change the rate constant of reactions in GEOS-Chem? #1002

Closed jinlx closed 2 years ago

jinlx commented 3 years ago

Hi there,

I am trying to update the rate constant of XYLE + OH in old version (2.31d-11) to what Kelvin recent reported in his 2021 ACP paper (1.7d-11). One spot I found I may need to modify is the value in ./CodeDir/KPP/Tropchem/Tropchem.eqn. I was wondering if there is anything else I need to do to modify the reactions

Cheers, Lixu

yantosca commented 3 years ago

Thanks for writing @jinlx. You would need to change the reaction rate in the Tropchem.eqn file (in your version) and then rebuild the mechanism with KPP. Please see: https://kpp.readthedocs.io for instructions.

Also note: We now recommend using the fullchem option with 47 levels rather than tropchem. See this Github issue: https://github.com/geoschem/geos-chem/issues/839

jinlx commented 3 years ago

Appreciate the comment Bob! That's useful information to know. Just a quick follow-up with the question. I tried compilling KPP after loading all requirement library. I encountered the error below. Do you have any insights in fixing this?

I suppose that what I really need to do is 1) change either Tropchem.eqn or Custom.eqn (recommended in the doc) and then recompile the GC by selecting specific Chemistry. Correct me if I am wrong.

code_matlab.c: In function ‘MATLAB_FunctionBegin’:
code_matlab.c:592:8: warning: variable ‘name’ set but not used [-Wunused-but-set-variable]
  592 | char * name;
      |        ^~~~
  gcc -g -Wall -c debug.c
  gcc -g -Wall y.tab.o lex.yy.o scanner.o scanutil.o kpp.o gen.o code.o code_c.o code_f77.o code_f90.o code_matlab.o debug.o -L/usr/lib64 -lfl -o kpp
/usr/bin/ld: cannot find -lfl
collect2: error: ld returned 1 exit status
make[1]: *** [kpp] Error 1
make[1]: Leaving directory `/home/lj152920/GC/KPP/kpp-2.2.3_01/src'
yantosca commented 3 years ago

Thanks @jinlx. You need to have flex loaded onto your system. This is usually in /usr/bin/flex on most Linux systems. If your system doesn't have it you can build it with Spack.

jinlx commented 2 years ago

Thanks for checking it Bob! I loaded flex before compilation. Do you think if it could be version/package issues?

Here are packages and versions I used: 1) C compiler (ifort Version 2021.1.2); 2) flex 2.6.4; 3) Python 3.8.5.

Cheers, Lixu

yantosca commented 2 years ago

You might have to set the FLEX_HOME environment variable to point to the location of the flex library. If FLEX_HOME isn't defined then it will assume lib64, which may or may not be correct for your system.

# 3. The complete pathname of the FLEX library (libfl.a).
#    On many systems this is either:
#    /usr/lib, /usr/lib64, /usr/local/util/lib/flex

ifndef FLEX_HOME
 FLEX_LIB_DIR=/usr/lib64
else
 FLEX_LIB_DIR=${FLEX_HOME}/lib64
endif
yantosca commented 2 years ago

Or you can just modify the FLEX_LIB_DIR setting in Makefile.defs to point to the proper path on your system.

jinlx commented 2 years ago

Thanks Bob! You are right. The issue is caused by that GCC is not able to find flex directory. The bug is fixed after setting up flex directory.