This repository contains the code used to produce all results in the preprint: Scientific Machine Learning for Modeling and Simulating Complex Fluids.
The scripts used to train and test RUDEs on shear rheometric data were developed using Julia v1.8.3, with the following packages: Flux v0.13.9, Optimization v3.10.0, Optimisers v0.2.14, OptimizationOptimisers v0.1.1, SciMLSensitivity v7.11.1, DifferentialEquations v7.6.0, Zygote v0.6.51, Enzyme v0.10.12, PyPlot v2.11.0, OrdinaryDiffEq v6.35.1, DataInterpolations v3.10.1, BSON v0.3.6, and FFTW v1.5.0.
Computational fluid dynamics simulations were performed using OpenFOAM v9, with the rheoTool v5.0 toolbox.
The scripts used to process experimental linear response data and to plot OpenFOAM simulation results were developed using Python 3.8.5, with the following packages: NumPy 1.19.2, Matplotlib 3.3.2, SciPy 1.5.2, CSV 1.0, and pandas 1.1.3.
rude.jl
: Julia script to generate synthetic shear stress LAOS data for the Giesekus model, train a RUDE using this data, and test the RUDE on shear and normal stress data in LAOS as well as shear stress data in shear startuptbnn.bson
: pre-trained model weights for a RUDE trained using therude.jl
scriptOpenFOAM
: directory containing the files needed to simulate a 4:1 contraction flowGiesekus
: directory containing the setup files for an OpenFOAM simulation of the Giesekus model, including the mesh file (system/blockMeshDict
), details for the integration and finite volume schemes (system/fvSchemes
andsystem/fvSolution
), definition of the constitutive model (constant/constitutiveProperties
), and initial conditions (0
)Oldroyd-BLog
: directory containing the setup files for an OpenFOAM simulation of the Oldroyd-B model (defined by the log-conformation tensor). Same file structure as theGiesekus
directoryRUDE
: directory containing the setup files for an OpenFOAM simulation of a trained RUDE. Same file structure as theGiesekus
directory, with three additional files (weights1.txt
,weights2.txt
, andweights3.txt
) containing the pre-trained weights for the TBNN layers obtained using therude.jl
scriptsimdata
: directory containing selected results from the OpenFOAM simulations, including centerline velocities, velocity profiles, the velocity field, and streamlinesmake_plots.py
: Python script for plotting the simulation results contained insimdata
data
: directory containing experimental data for the metal-crosslinked polymer hydrogel. Includes the raw data output by TRIOS (raw
) and pre-processed CSV files for LAOS and SAOS testsfitlr.py
: Python script to fit the linear response of the gel to a single-mode Maxwell modelrude.jl
: Julia script to train a RUDE using the LAOS data, and predict the shear and normal stress response in another LAOS experiment (as well as an amplitude-sweep in LAOS)weights_201.bson
: partially pre-trained model, terminated after an epoch of 200 training iterations on the lowest-amplitude LAOS experimentweights_402.bson
: partially pre-trained model, terminated after an epoch of 200 training iterations on the two lowest-amplitude LAOS experiments, with training initialized using theweights_201.bson
networkweights_603.bson
: fully pre-trained model, terminated after an epoch of 200 training iterations on all three training LAOS curves, with training initialized using theweights_402.bson
network
Inquiries and suggestions can be directed to krlennon[at]mit.edu.