Skip to content

Add kcl na2s#68

Merged
chengcli merged 5 commits intomainfrom
cli/add_kcl_na2s
Jan 2, 2026
Merged

Add kcl na2s#68
chengcli merged 5 commits intomainfrom
cli/add_kcl_na2s

Conversation

@chengcli
Copy link
Owner

@chengcli chengcli commented Jan 2, 2026

No description provided.

Copilot AI review requested due to automatic review settings January 2, 2026 16:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for KCl and Na2S vapor pressure calculations and introduces a rainout option for adiabatic extrapolation. Key changes include:

  • Addition of KCl (Lodders) and Na2S (Visscher) vapor pressure functions with temperature derivatives
  • Introduction of a rainout parameter to ExtrapOptions for dropping condensates during extrapolation
  • Refactoring of the extrapolate_dz function to simplify the iteration logic

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/vapors/vapor_functions.h Adds kcl_lodders and na_h2s_visscher vapor pressure functions with derivatives
src/func_table.cpp Registers new vapor functions in CPU function table and names registry
src/func_table.cu Registers new vapor functions in CUDA function table
src/thermo/thermo.hpp Adds rainout flag to ExtrapOptions and formatting improvements to report output
src/thermo/extrapolate_ad.cpp Implements rainout logic in extrapolation methods and simplifies iteration
src/kinetics/kinetics.hpp Adds formatting to report output
python/csrc/pythermo.cpp Exposes rainout parameter in Python bindings for extrapolation methods
src/utils/utils_dispatch.cu Changes include path format and comments out dispatch definitions
src/utils/utils_dispatch.cpp Changes include path format and comments out CUDA conditional compilation
src/CMakeLists.txt Reorders source file glob patterns

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

"extrapolate_dlnp",
[](kintera::ThermoXImpl &self, torch::Tensor temp, torch::Tensor pres,
torch::Tensor xfrac, double dlnp, double ds_dlnp, bool verbose) {
torch::Tensor xfrac, double dlnp, double ds_dlnp, double rainout,
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rainout parameter should be a bool type, not double. The parameter is used as a boolean in the ExtrapOptions and the function signature should match.

Copilot uses AI. Check for mistakes.
[](kintera::ThermoXImpl &self, torch::Tensor temp, torch::Tensor pres,
torch::Tensor xfrac, double dz, double grav, double ds_dz,
bool verbose) {
double rainout, bool verbose) {
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rainout parameter should be a bool type, not double. The parameter is used as a boolean in the ExtrapOptions and the function signature should match.

Copilot uses AI. Check for mistakes.
Comment on lines +166 to +171
double logp = 7.611 - 11382. / T;
return log(1.E5) + logp;
}

DISPATCH_MACRO
inline double kcl_lodders_ddT(double T) { return 11382. / (T * T); }
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function lacks documentation explaining the source of the constants (7.611, 11382.) and the units expected for T and the returned value. Consider adding a brief comment describing the Lodders formulation and parameter units.

Suggested change
double logp = 7.611 - 11382. / T;
return log(1.E5) + logp;
}
DISPATCH_MACRO
inline double kcl_lodders_ddT(double T) { return 11382. / (T * T); }
// Lodders-type parameterization of KCl saturation vapor pressure.
// T: temperature in Kelvin.
// The constants 7.611 (dimensionless intercept) and 11382. (in Kelvin)
// are empirical coefficients from the Lodders formulation for log(p_sat).
// This function returns the natural logarithm of the saturation vapor
// pressure p_sat expressed in Pascals.
double logp = 7.611 - 11382. / T;
return log(1.E5) + logp;
}
DISPATCH_MACRO
inline double kcl_lodders_ddT(double T) {
// Temperature derivative of the Lodders KCl log(p_sat) expression.
// T is in Kelvin; the returned value is d/dT [log(p_sat [Pa])].
return 11382. / (T * T);
}

Copilot uses AI. Check for mistakes.
Comment on lines +174 to +179
inline double na_h2s_visscher(double T) {
// double log10p = 8.55 - 13889. / T - 0.5 * log10(pH2S / 1E5);
// return 1.E5 * pow(10., log10p);
double a = 8.55;
double b = 13889.;
return (15. + 2. * a - 2. * b / T) * log(10.);
Copy link

Copilot AI Jan 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commented-out code and the magic number 15. in the implementation need explanation. Add documentation clarifying the relationship between the commented formula and the actual implementation, and explain the derivation of the constant 15.

Copilot uses AI. Check for mistakes.
@chengcli chengcli merged commit 3fbdcf2 into main Jan 2, 2026
3 checks passed
@chengcli chengcli deleted the cli/add_kcl_na2s branch January 2, 2026 23:09
@github-actions
Copy link

github-actions bot commented Jan 2, 2026

🎉 Released v1.2.8!

What's Changed

Full Changelog: v1.2.7...v1.2.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant