Skip to content

equinor/neqsim-parameterfitting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

79 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NeqSim Parameter Fitting

Run Tests Validate Data License

Central repository for experimental data, parameter fitting, and model validation for NeqSim - the thermodynamic and fluid behavior simulation library.

πŸ“‹ Overview

This repository provides:

  • Experimental Data: Curated datasets for thermodynamic properties (VLE, density, viscosity, etc.)
  • Fitting Utilities: Python package for parameter optimization
  • Evaluation Tools: Standard metrics and visualization for model comparison
  • Parameter Registry: Version-controlled fitted parameters
  • Report Generation: Automated documentation of fitting results

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/equinor/neqsim-parameterfitting.git
cd neqsim-parameterfitting

# Install Python package
pip install -e ./python

# Or with all optional dependencies
pip install -e "./python[all]"

Basic Usage

from neqsim_fitting.data import load_vle_data, get_data_summary
from neqsim_fitting.evaluation import calculate_all_metrics, parity_plot
from neqsim_fitting.fitting import VLEFitter

# Load experimental data
df = load_vle_data('data/thermodynamics/VLE/water-CO2.csv')
print(get_data_summary(df))

# Fit parameters
fitter = VLEFitter('CO2', 'water', equation_of_state='cpa')
result = fitter.fit_kij(df, fit_kij_T=True)

# Evaluate results
print(result.summary())
parity_plot(df['x1'], result.calculated_values)

πŸ“ Repository Structure

neqsim-parameterfitting/
β”œβ”€β”€ data/                       # Experimental datasets
β”‚   β”œβ”€β”€ schema/                 # JSON schemas for validation
β”‚   β”œβ”€β”€ physicalproperties/     # Viscosity, conductivity, etc.
β”‚   └── thermodynamics/         # VLE, density, Cp, etc.
β”œβ”€β”€ example/                    # Jupyter notebooks
β”‚   β”œβ”€β”€ thermodynamics/
β”‚   └── physicalproperties/
β”œβ”€β”€ parameters/                 # Fitted parameter registry
β”‚   β”œβ”€β”€ registry.yaml           # Index of all parameters
β”‚   └── fitted/                 # Individual parameter files
β”œβ”€β”€ python/                     # Python utilities package
β”‚   └── neqsim_fitting/
β”œβ”€β”€ reports/                    # Generated reports
β”‚   β”œβ”€β”€ templates/              # Jinja2 templates
β”‚   └── generated/              # Output reports
β”œβ”€β”€ scripts/                    # Utility scripts
β”œβ”€β”€ src/                        # Java fitting code
β”œβ”€β”€ templates/                  # Notebook templates
└── pyproject.toml              # Python project config

πŸ“Š Available Data

Property Pure Components Binary Mixtures
VLE - CO2-water, methane-water, nitrogen-water, oxygen-water
Density hydrogen, water, MEG, TEG hydrogen-methane
Viscosity hydrogen, water hydrogen-methane
Heat Capacity CO2, hydrogen, methane, nitrogen, oxygen, TEG, water -
Thermal Conductivity hydrogen, TEG hydrogen-methane
Speed of Sound - hydrogen-methane

πŸ”§ Parameter Fitting Workflow

  1. Load Data using standardized loaders
  2. Validate against schemas
  3. Evaluate Baseline model performance
  4. Fit Parameters using optimization
  5. Validate Results with metrics and plots
  6. Export fitted parameters and reports

See the template notebooks for complete examples.

πŸ“ˆ Fitted Parameters

All fitted parameters are stored in the parameters/ directory with:

  • YAML format for easy reading and version control
  • Complete metadata (valid range, data sources, metrics)
  • Usage examples for NeqSim

Browse the parameter registry for available parameters.

πŸ“– Documentation

πŸ”¬ Using with NeqSim

from neqsim.thermo.thermoTools import fluid, TPflash

# Create fluid with fitted parameters
fluid1 = fluid('cpa')
fluid1.addComponent('CO2', 1.0)
fluid1.addComponent('water', 100.0)
fluid1.autoSelectMixingRule()

# Perform flash calculation
fluid1.setTemperature(25, 'C')
fluid1.setPressure(50, 'bara')
TPflash(fluid1)

# Get results
x_CO2 = fluid1.getPhase('aqueous').getComponent('CO2').getx()
print(f"CO2 solubility: {x_CO2:.6f} mol/mol")

See the NeqSim Wiki for more information.

πŸ› οΈ Setting up Maven Project (Java)

Call mvn validate to install the NeqSim core jar file located in resources folder to a local maven repository. Then the neqsim package shall be available for the java code. Try it out by calling mvn test.

See notebook on how to work with the NeqSim parameter database, and the description in the neqsim wiki.

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Quick contribution guide:

  1. Add experimental data: Follow the data format standards
  2. Fit new parameters: Use the template notebooks
  3. Report issues: Use the issue templates

πŸ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

πŸ”— Related Projects

πŸ“§ Contact

About

NeqSim experimental database and parameter fitting project

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •