Codebase for mitigating distribution shift in MLHS using tangent-space reegularized algorithm based on the paper [1] by Jiaxi Zhao and Qianxiao Li.
Install the package and set the environment
git clone git@github.com:jiaxi98/ml4dynamics.git
mkdir venv
mkdir venv/ml4dynamics
python -m venv venv/ml4dynamics
source venv/ml4dynamics/bin/activate
cd ml4dynamics
pip install --upgrade pip
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
pip install --upgrade "jax[cuda12_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
pip install -e .For discussion related to compatibility of jax and torch, please refer to: link1, link2, link3
Both filter and correction SGS stresses are calculated, modified the corresponding config file ks.yaml to switch between different boundary conditions: periodic and Dirichlet-Neumann BC.
python ml4dynamics/dataset_utils/generate_ks.pyOne can train on 1 or 10 trajectories. To verify the performance, one can verify on one trajectory
to visualize and also on 10 trajectory to see the statistics, check ml4dynamics.utils.utils.eval_a_posteriori
for more details.
python ml4dynamics/trainers/train_jax.py -c ksThis codebase supports both the training of the global (mesh to mesh) and local (pt to pt) SGS model. To switch between these two modes, please modify the config file accordingly. Below are two examples for global/local training.
- global
train:
# input: ["u", "u_x", "u_xx", "x"]
# input: 4
input: global- local
train:
input: ["u", "u_x", "u_xx", "x"]
# input: 4
# input: globalNotice for local training, two choices to specify the input features are provided.
The first choice
If you find this codebase useful for your research, please consider citing:
@article{zhao2025mitigating,
title={Mitigating Distribution Shift in Machine Learning--Augmented Hybrid Simulation},
author={Zhao, Jiaxi and Li, Qianxiao},
journal={SIAM Journal on Scientific Computing},
volume={47},
number={2},
pages={C475--C500},
year={2025},
publisher={SIAM}
}
@inproceedings{zhao2025generative,
title={Generative subgrid-scale modeling},
author={Zhao, Jiaxi and Arisaka, Sohei and Li, Qianxiao},
booktitle={ICLR 2025 Workshop on Machine Learning Multiscale Processes},
year={2025}
}