acces-coexsist

Learning simulation parameters from experimental data, from the micro to the macro, from laptops to clusters.

https://github.com/uob-positron-imaging-centre/acces-coexsist

Science Score: 75.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    3 of 7 committers (42.9%) from academic institutions
  • Institutional organization owner
    Organization uob-positron-imaging-centre has institutional domain (www.birmingham.ac.uk)
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.2%) to scientific vocabulary

Keywords

calibration computational-fluid-dynamics discrete-element-method granular medical-imaging optimization parameter-estimation parameter-tuning physics-simulation simulation
Last synced: 4 months ago · JSON representation ·

Repository

Learning simulation parameters from experimental data, from the micro to the macro, from laptops to clusters.

Basic Info
Statistics
  • Stars: 19
  • Watchers: 3
  • Forks: 4
  • Open Issues: 2
  • Releases: 2
Topics
calibration computational-fluid-dynamics discrete-element-method granular medical-imaging optimization parameter-estimation parameter-tuning physics-simulation simulation
Created over 5 years ago · Last pushed about 2 years ago
Metadata Files
Readme License Citation

README.md

PyPI version Documentation Status CI Status Language grade: Python Colab example License: GPL-3.0

CoExSiST & ACCES

Data-Driven Evolutionary Calibration & Optimisation of Simulations

A Python library for autonomously learning simulation parameters from experimental data, from the micro to the macro, from laptops to clusters. This is done using either of two closely related frameworks:

  • CoExSiST: Coupled Experimental-Simulational Study Tool.
  • ACCES: Autonomous Characterisation and Calibration via Evolutionary Simulation.

Both libraries learn a given set of free parameters, such that an experiment is synchronised with an equivalent simulation; this synchronisation is done in one of two ways:

  • CoExSiST calibrates microscopically: in a Discrete Element Method (DEM) context, all simulated particles follow their experimental counterparts exactly. Naturally, this technique is limited to dilute systems and experimental imaging techniques that can capture the 3D position of all moving particles (e.g. PIV) - however, it provides information about the fundamental aspects of particle collision.
  • ACCES calibrates / optimises macroscopically: a given simulation reproduces a system-specific macroscopic quantity (e.g. residence time distribution, angle of repose). This technique is completely agnostic to the simulation method and the quantity to be reproduced. For example, it can train coarse-grained DEM simulations, using larger meso-particles to model multiple smaller ones.

ACCES is ready for production use; it was successfully used to calibrate coarse-grained DEM digital twins of GranuTools equipment (Andrei Leonard Nicusan and Dominik Werner, paper under review), CFDEM fluidised beds (Hanqiao Cha, paper under review) and even signal processing parameters in a PET scanner model (Matthew Herald, paper under review).

Calibrated GranuDrum Example of an ACCES-calibrated DEM Digital Twin of a GranuTools GranuDrum; the calibration was done effectively against a single experimental data point - a photograph of the free surface shape yielded by MCC particles (left panel). The occupancy grid of a LIGGGHTS simulation was optimised against the free surface shape (right panel). The two superimposed grids amount to 4 mm² dissimilarity (dark blue pixels, middle panel).

ACCES was implemented in the coexist.Access class, providing an interface that is easy to use, but powerful enough to automatically parallelise arbitrary Python scripts through code inspection and metaprogramming. It was used successfully from laptop-scale shared-memory machines to multi-node supercomputing clusters.

Getting Started

This is a pure Python package that does not require any extra system configuration, supporting Python 3.6 and above (though it might work with even older versions) - to install it from PyPI, simply run:

pip install coexist

Or you can install the development version from the GitHub repository:

pip install git+https://github.com/uob-positron-imaging-centre/Coexist

Examples

The documentation website contains an ACCES tutorial with explained code and output figures produced by coexist; all public functionality is fully documented in the manual.

Want something more hands on? Check out the examples folder for example scripts using coexist.Coexist and coexist.Access; examples/access_simple is a very simple, hackable example script (remember that the simulation_script.py can execute anything). For a more involved, complete calibration of a GranuTools GranuDrum digital twin - using LIGGGHTS - see our collection of peer-reviewed digital twins repository.

GranuDrum ACCES Example

The coexist.plots submodule can plot the convergence of ACCES onto optimally-calibrated parameters - or check intermediate results while your 50-hour simulations runs:

Convergence Plot

Show me some code already...

Alright, here's the gist of it: instead of having to rewrite your complex simulation into a function for calibration / optimisation (which is what virtually all optimisation frameworks require...), ACCES takes in an entire simulation script; here's a simple example, say in a file called simulation_script.py:

```python

File: simulation_script.py

ACCESS PARAMETERS START

import coexist

parameters = coexist.create_parameters( variables = ["CED", "CoR", "Epsilon", "Mu"], minimums = [-5, -5, -5, -5], maximums = [+5, +5, +5, +5], values = [0, 0, 0, 0], # Optional, initial guess )

access_id = 0 # Optional, unique ID for each simulation

ACCESS PARAMETERS END

Extract the free parameters' values - ACCES will modify / optimise them.

x, y, z, t = parameters["value"]

Define the error value in any way - run a simulation, analyse data, etc.

For simplicity, here's an analytical 4D Himmelblau function with 8 global

and 2 local minima - the initial guess is very close to the local one!

error = (x2 + y - 11)2 + (x + y2 - 7)2 + z * t ```

Then you can run in a separate script or Python console:

```python

File: access_learn.py

import coexist

Use ACCESS to learn a simulation's parameters

access = coexist.Access("simulationscript.py") access.learn( numsolutions = 10, # Number of solutions per epoch targetsigma = 0.1, # Target std-dev (accuracy) of solution randomseed = 42, # Reproducible / deterministic optimisation )

Or simply

coexist.Access("simulationscript.py").learn(randomseed = 42)

```

That's it - ACCES will take the simulation_script.py, modify the free parameters, run the script in parallel (either on all processors of your local machine or on a distributed supercomputer) and optimise the error you defined; it'll look something like this:

```

Starting ACCES run at 08:32:23 on 01/02/2022 in directory access_seed42.

Epoch 0 | Population 10

Scaled overall standard deviation: 1.0 CED CoR Epsilon Mu estimate 0.0 0.000000 0.000000 0.000000 uncertainty 4.0 4.000050 4.000100 4.000150 scaled_std 1.0 1.000013 1.000025 1.000038

    CED       CoR   Epsilon        Mu       error

0 1.218868 -4.159988 3.001880 3.762400 331.093228 1 -3.095859 -4.967675 0.511374 -1.265018 252.732762 2 -0.067205 -3.412218 3.517680 3.111284 239.466423 3 0.264123 4.509021 1.870084 -3.437299 219.638764 4 1.475003 -3.835578 3.513889 -0.199711 243.967225 5 -0.739449 -2.723752 4.825957 -0.618141 170.752129 6 -1.713311 -1.408552 2.129290 1.461831 138.135979 7 1.650930 1.723306 2.333195 -1.625721 44.785098 8 -2.048971 -3.255132 2.463979 4.516059 114.660635 9 -0.455790 -3.360668 -3.298007 2.602469 206.454823 Total function evaluations: 10

================================================================================

Epoch 1 | Population 10

...

...

Epoch 31 | Population 10

Scaled overall standard deviation: 0.1032642976669169 CED CoR Epsilon Mu estimate 3.621098 -1.748473 4.999445 -4.992881 uncertainty 0.052355 0.078080 0.284105 0.180196 scaled_std 0.013089 0.019520 0.071026 0.045049

      CED       CoR   Epsilon        Mu      error

310 3.574473 -1.650134 4.999374 -4.901913 -23.996813 311 3.582026 -1.756384 4.863496 -4.973417 -24.071692 312 3.628789 -1.616891 4.859678 -4.992656 -23.386000 313 3.662351 -1.782704 4.982040 -4.998059 -24.478008 314 3.594971 -1.725715 4.999877 -4.898257 -24.269162 315 3.577725 -1.744971 4.998411 -4.956502 -24.629198 316 3.613914 -1.747412 4.983253 -4.996630 -24.690880 317 3.579212 -1.774811 4.852262 -4.972910 -24.055219 318 3.634952 -1.784927 4.999971 -4.999863 -24.783959 319 3.647169 -1.872419 4.999971 -4.978640 -24.685207 Total function evaluations: 320

Optimal solution found within target_sigma, i.e. 10.0%: sigma = 0.08390460663313491 < 0.1

================================================================================ The best result was found in 32 epochs: CED CoR Epsilon Mu error value 3.569249 -1.813354 4.995112 -4.994052 -24.920092 std 0.042168 0.060116 0.203900 0.140874

These results were found for the job:

access_seed42/results/parameters.284.pickle

```

And you can access (pun intended) the results - even as ACCES is running - using:

```python

import coexist data = coexist.AccessData.read("access_seed42") data

AccessData

paths ╎ AccessPaths(...) parameters ╎ value min max sigma ╎ CED 3.569249 -5.0 5.0 0.052355 ╎ CoR -1.813354 -5.0 5.0 0.078080 ╎ Epsilon 4.995112 -5.0 5.0 0.284105 ╎ Mu -4.994052 -5.0 5.0 0.180196 population ╎ 10 numepochs ╎ 32 target ╎ 0.1 seed ╎ 42 epochs ╎ DataFrame(CEDmean, CoRmean, Epsilonmean, Mumean, CEDstd, ╎ CoRstd, Epsilonstd, Mustd, overallstd) epochsscaled ╎ DataFrame(CEDmean, CoRmean, Epsilonmean, Mumean, CEDstd, ╎ CoRstd, Epsilonstd, Mustd, overallstd) results ╎ DataFrame(CED, CoR, Epsilon, Mu, error) results_scaled ╎ DataFrame(CED, CoR, Epsilon, Mu, error) ```

In this case a global optimum was found within 320 evaluations - this is of course problem-dependent, but you'll see that the optimum is often found much earlier if you check intermediate results (which you probably will when calibrating / optimising long-running simulations).

A tutorial with more detailed explanations is available here, including generating plots, checking intermediate results and running simulations on a SLURM-managed distributed cluster.

Contributing

This library aims to be the state-of-the-art for simulation calibration, developed in the open using modern, collaborative coding approaches - no dragons shall be dwelling in the codebase. You are more than welcome to contribute to this library in the form of code improvements, documentation or helpful examples; please submit them either as:

We are more than happy to discuss the library architecture and calibration / optimisation approach with any potential contributors and users.

Acknowledgements and Funding

The authors gratefully acknowledge funding from the following UK funding bodies and industrial partners:

M²E³D: Multiphase Materials Exploration via Evolutionary Equation Discovery
Royce Materials 4.0 Feasibility and Pilot Scheme Grant, £57,477

CoExSiST: Coupled Experimental-Simulational Technique
EPSRC MAPP Grant, Feasibility Study, £60,246

ACCES: Autonomous Calibration and Characterisation via Evolutionary Simulation
EPSRC IAA, Follow-Up Grant to CoExSiST, £52,762

Improving ACCES: Towards the Multi-Tool Multi-Parameter Optimisation of Complex Particulate Systems
EPSRC MAPP, Grant, £48,871 + £48,871 matched funding from GranuTools Belgium

Thank you.

Citing

If you use this library in your research, you are kindly asked to cite:

[Paper after publication]

Until the ACCES paper is published, you may cite this repository:

Nicusan, A., Werner, D., Sykes, J. A., Seville, J., & Windows-Yule, K. (2022). ACCES: Autonomous Characterisation and Calibration via Evolutionary Simulation (Version 0.2.0) [Computer software]

ACCES is built on top of the excellent CMA-ES evolutionary algorithm - specifically the pycma implementation. If you use ACCES in your research, please also cite:

Nikolaus Hansen, Youhei Akimoto, and Petr Baudis. CMA-ES/pycma on Github. Zenodo, DOI:10.5281/zenodo.2559634, February 2019.

License and Commercial Integration

This library - in its general, domain-agnostic form - is free and open-source, published under the GNU General Public License v3.0.

If you are a company and would like to integrate ACCESS into your work - e.g. ACCESS-enabled equipment or general simulation calibration - please send an email to a.l.nicusan@bham.ac.uk to discuss commercial development of specific tools for your application. Relicensing for a closed-source / commercial project can be considered on an individual basis.

Copyright (C) 2020-2023 the Coexist developers. Until now, this library was built directly or indirectly through the brain-time of:

  • Andrei Leonard Nicusan (University of Birmingham)
  • Dominik Werner (University of Birmingham)
  • Jack Sykes (University of Birmingham)
  • Dr. Kit Windows-Yule (University of Birmingham)
  • Prof. Jonathan Seville (University of Birmingham)
  • Albert Bauer (TU Berlin)

Thank you.

Owner

  • Name: UoB Positron Imaging Centre
  • Login: uob-positron-imaging-centre
  • Kind: organization
  • Location: University of Birmingham, UK

The Positron Imaging Centre is home to the technique of Positron Imaging Particle Tracking (PEPT), invented here, at Birmingham.

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, you are kindly asked to cite it as below."
authors:
  - family-names: Nicusan
    given-names: Andrei-Leonard
    orcid: https://orcid.org/0000-0002-4796-8719
  - family-names: Werner
    given-names: Dominik
  - family-names: Sykes
    given-names: Jack Alan
  - family-names: Seville
    given-names: Jonathan
  - family-names: Windows-Yule
    given-names: Kit
    orcid: https://orcid.org/0000-0003-1305-537X

title: "ACCES: Autonomous Characterisation and Calibration via Evolutionary Simulation"
version: 0.2.0
doi: 10.5281/zenodo.7215376
date-released: 2022-02-01
url: "https://github.com/uob-positron-imaging-centre/ACCES-CoExSiST"

GitHub Events

Total
  • Watch event: 4
  • Fork event: 1
Last Year
  • Watch event: 4
  • Fork event: 1

Committers

Last synced: almost 2 years ago

All Time
  • Total Commits: 182
  • Total Committers: 7
  • Avg Commits per committer: 26.0
  • Development Distribution Score (DDS): 0.242
Past Year
  • Commits: 11
  • Committers: 1
  • Avg Commits per committer: 11.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Andrei Leonard Nicusan a****n@b****k 138
Dominik Werner d****3@s****k 22
jacksykes17 7****7 8
jacksykes17 j****3@s****k 5
D-werner-bham 5****m 4
Andrei Nicusan (Chemical Engineering) n****l@b****r 3
Andrei Nicusan (Chemical Engineering) n****l@b****r 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 3
  • Total pull requests: 2
  • Average time to close issues: 5 days
  • Average time to close pull requests: 23 minutes
  • Total issue authors: 2
  • Total pull request authors: 2
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.5
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • dwerner95 (2)
Pull Request Authors
  • BenDJenkins (1)
  • anicusan (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

requirements.txt pypi
  • astunparse >=1.6.3
  • cma >=3.0.3
  • matplotlib >=3.2.1
  • numpy >=1.17.3
  • pandas >=1.0.5
  • plotly >=4.4.1
  • pyevtk >=1.1.1
  • scipy >=1.4.1
  • toml >=0.10.2
  • tqdm >=4.41.1
requirements_extra.txt pypi
  • Sphinx >=4.1
  • ipython >=5.5.0
  • numpydoc >=1.1
  • pydata-sphinx-theme >=0.6.3
  • pytest >=3.6.4
.github/workflows/ci.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
pyproject.toml pypi
setup.py pypi