Skip to content

Commit

Permalink
WIP: Define Diffusive Mixing Coupling
Browse files Browse the repository at this point in the history
  • Loading branch information
micheltakken committed Nov 21, 2024
1 parent baffaa7 commit db4be9a
Show file tree
Hide file tree
Showing 6 changed files with 302 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/Hybrid/OoC-1.JSON
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"mixtures": [
{
"species": [0],
"concentrations": [1.0]
"concentrations": [1.1]
}
],
"pumps": [
Expand All @@ -182,7 +182,7 @@
"mixtureInjections": [
{
"mixture": 0,
"channel": 1,
"channel": 4,
"t0": 0.0
}
]
Expand Down
253 changes: 253 additions & 0 deletions examples/Hybrid/OoC-2.JSON
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
{
"network": {
"nodes": [
{
"x": 0.0,
"y": 0.0,
"z": 0.0,
"ground": true
},
{
"x": 1e-3,
"y": 2e-3,
"z": 0.0
},
{
"x": 1e-3,
"y": 1e-3,
"z": 0.0
},
{
"x": 1e-3,
"y": 0.0,
"z": 0.0
},
{
"x": 2e-3,
"y": 2e-3,
"z": 0.0
},
{
"x": 1.75e-3,
"y": 1e-3,
"z": 0.0
},
{
"x": 2e-3,
"y": 0.0,
"z": 0.0
},
{
"x": 2e-3,
"y": 1.25e-3,
"z": 0.0
},
{
"x": 2e-3,
"y": 0.75e-3,
"z": 0.0
},
{
"x": 2.25e-3,
"y": 1e-3,
"z": 0.0
},
{
"x": 3e-3,
"y": 1e-3,
"z": 0.0,
"ground": true
}
],
"channels": [
{
"node1": 0,
"node2": 1,
"width": 1e-4,
"height": 1e-4
},
{
"node1": 0,
"node2": 2,
"width": 1e-4,
"height": 1e-4
},
{
"node1": 0,
"node2": 3,
"width": 1e-4,
"height": 1e-4
},
{
"node1": 1,
"node2": 4,
"width": 1e-4,
"height": 1e-4
},
{
"node1": 2,
"node2": 5,
"width": 1e-4,
"height": 1e-4
},
{
"node1": 3,
"node2": 6,
"width": 1e-4,
"height": 1e-4
},
{
"node1": 4,
"node2": 7,
"width": 1e-4,
"height": 1e-4
},
{
"node1": 6,
"node2": 8,
"width": 1e-4,
"height": 1e-4
},
{
"node1": 9,
"node2": 10,
"width": 1e-4,
"height": 1e-4
}
],
"modules": [
{
"position": [1.75e-3, 0.75e-3],
"size": [5e-4, 5e-4],
"nodes": [5, 7, 8, 9]
}
]
},
"simulation": {
"platform": "Ooc",
"type": "Hybrid",
"resistanceModel": "Poiseuille",
"mixingModel": "Diffusion",
"fluids": [
{
"name": "Water",
"concentration": 1,
"density": 1000,
"viscosity": 0.001
}
],
"tissues": [
{
"name": "Liver",
"species": [0],
"Vmax": [0.1571428],
"kM": [0.022285714]
}
],
"species": [
{
"name": "O2",
"diffusivity": 1e-8,
"saturationConcentration": 1.0,
"molecularSize": 0.0
}
],
"mixtures": [
{
"species": [0],
"concentrations": [1.1]
}
],
"pumps": [
{
"channel":0,
"type": "PumpPressure",
"deltaP": 1000
},
{
"channel":1,
"type": "PumpPressure",
"deltaP": 1000
},
{
"channel":2,
"type": "PumpPressure",
"deltaP": 1000
}
],
"fixtures": [
{
"name": "Setup #1",
"phase": 0,
"mixtureInjections": [
{
"mixture": 0,
"channel": 4,
"t0": 0.0
}
]
}
],
"activeFixture": 0,
"settings": {
"simulators": [
{
"Type": "Organ",
"name": "Liver-Test",
"stlFile": "../examples/STL/cross.stl",
"tissue": 0,
"organStlFile": "../examples/STL/cube.stl",
"charPhysLength": 1e-4,
"charPhysVelocity": 1e-1,
"alpha": 0.1,
"resolution": 20,
"epsilon": 1e-1,
"tau": 0.55,
"moduleId": 0,
"Openings": [
{
"node": 5,
"normal": {
"x": 1.0,
"y": 0.0,
"z": 0.0
},
"width": 1e-4,
"height": 1e-4
},
{
"node": 7,
"normal": {
"x": 0.0,
"y": -1.0,
"z": 0.0
},
"width": 1e-4,
"height": 1e-4
},
{
"node": 8,
"normal": {
"x": 0.0,
"y": 1.0,
"z": 0.0
},
"width": 1e-4,
"height": 1e-4
},
{
"node": 9,
"normal": {
"x": -1.0,
"y": 0.0,
"z": 0.0
},
"width": 1e-4,
"height": 1e-4
}
]
}
]
}
}
}
2 changes: 2 additions & 0 deletions src/simulation/MixingModels.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ class DiffusionMixingModel : public MixingModel<T> {
* @brief Propagate all the species through a network for a steady-state simulation
*/
void propagateSpecies(arch::Network<T>* network, Simulation<T>* sim) override;

void initNodeOutflow(Simulation<T>* sim, std::vector<DiffusiveMixture<T>>& tmpMixtures);

void printTopology();

Expand Down
33 changes: 32 additions & 1 deletion src/simulation/MixingModels.hh
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,38 @@ void DiffusionMixingModel<T>::topologyAnalysis( arch::Network<T>* network, int n

template<typename T>
void DiffusionMixingModel<T>::propagateSpecies(arch::Network<T>* network, Simulation<T>* sim) {
// TODO

// Initial 1D "Input"
std::vector<DiffusiveMixture<T>> tmpMixtures;

// 1. Define the initial inflow into 1D (from pumps and CFD regions)
initNodeOutflow(sim, tmpMixtures);

// 2. Propagate the initial inflow through all subsequent channels
// 3. while (not done)
// 3.1 get next node outflow from latest inflows
// 3.2 propagate through channels again
// end
// 4. Store final concentrations in the concentration buffer of olbMixingSolver
// 5. clean Network
}

template<typename T>
void DiffusionMixingModel<T>::initNodeOutflow(Simulation<T>* sim, std::vector<DiffusiveMixture<T>>& tmpMixtures) {
// Add mixture injections
for (auto& [key, mixtureInjection] : sim->getMixtureInjections()) {
/** TODO:
*
*/
}
// Add CFD Simulator outflows
for (auto& [key, cfdSimulator] : sim->getCFDSimulators()) {
for (auto& [nodeId, opening] : cfdSimulator->getOpenings()) {
/** TODO:
*
*/
}
}
}

template<typename T>
Expand Down
10 changes: 10 additions & 0 deletions src/simulation/Simulation.hh
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,16 @@ namespace sim {
#endif

saveState();

// Couple the resulting CFD flow field to the AD fields
coupleNsAdLattices(cfdSimulators);

// Obtain overal steady-state concentration results
bool concentrationConverged = false;
while (!concentrationConverged) {
concentrationConverged = conductADSimulation(cfdSimulators);
this->mixingModel->propagateSpecies(network, this);
}
}

// Abstract Droplet simulation
Expand Down
3 changes: 3 additions & 0 deletions src/simulation/simulators/olbMixing.hh
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ bool lbmMixingSimulator<T>::hasAdConverged() const {
c = false;
}
}
if (this->step > 20000) {
c = true;
}
return c;
};

Expand Down

0 comments on commit db4be9a

Please sign in to comment.