A hybrid simulator for closed channel-based microfluidic devices
Project description
MMFT Hybrid Simulator
A Hybrid Simulator for Microfluidic Devices developed by the Chair for Design Automation at the Technical University of Munich as part of the Munich MicroFluidic Toolkit (MMFT). This simulator exploits the Modified Nodal Analysis (which is a simulation method on a high level of abstraction) to accelerate CFD simulations (using the LBM as implemented in the OpenLB library) of microfluidic devices.
For more information about our work on Microfluidics, please visit https://www.cda.cit.tum.de/research/microfluidics/.
If you have any questions, feel free to contact us via microfluidics.cda@xcit.tum.de or by creating an issue on GitHub.
System Requirements
The implementation should be compatible with any current C++ compiler supporting C++17 and a minimum CMake version 3.21. The python package requires Python version 3.7 or newer. The package is currently tested for Linux distributions.
Usage
C++
To use this library, include the following code in your cmake file:
include(FetchContent)
FetchContent_Declare(
hybridsim
GIT_REPOSITORY https://github.com/cda-tum/mmft-hybrid-simulator.git
GIT_TAG master
)
FetchContent_MakeAvailable(hybridsim)
target_link_libraries(${TARGET} PRIVATE hybridsim)
and include the library API header in your project file:
#include <baseSimulator.h>
#include <baseSimulator.hh>
Python
Install the python package
pip install mmft.hybridsim
and import the hybrid simulator in your code
from mmft import hybridsim
Example
To use the hybrid simulator, the network must be defined in a Network.JSON file.
A network is defined as a set of Nodes
, Channels
and CFD Modules
.
A Node
contains the x and y position on a Cartesian coordinate system, where the origin is the bottom-left corner of the microfluidic device:
{
"iD": 1,
"x": 2e-3,
"y": 1e-3
}
A Channel
connects two nodes (nA and nB) and has a width and a height:
{
"iD": 1,
"nA": 1,
"nB": 2,
"width": 1e-4,
"height": 1e-4
}
A CFD Module
is defined with type "LBM"
and contains paramaters for the LBM solver instance and information on the geometry of the CFD instance:
{
"iD": 0,
"Type":"LBM",
"name": "Test1-cross-0",
"stlFile": "/path/to/cross.stl",
"charPhysLength": 1e-4,
"charPhysVelocity": 1e-2,
"alpha": 0.01,
"resolution": 20,
"epsilon": 1e-1,
"tau": 0.55,
"posX": 3.75e-3,
"posY": 0.75e-3,
"sizeX": 5e-4,
"sizeY": 5e-4,
"Openings":
[
{
"nodeId": 4,
"normalX": 1.0,
"normalY": 0.0,
"width": 1e-4
},
{
"nodeId": 8,
"normalX": 0.0,
"normalY": -1.0,
"width": 1e-4
},
{
"nodeId": 9,
"normalX": 0.0,
"normalY": 1.0,
"width": 1e-4
},
{
"nodeId": 10,
"normalX": -1.0,
"normalY": 0.0,
"width": 1e-4
}
]
}
Most importantly, the geometry of the CFD Module
is described by a .STL file. The in-/outflow boundaries of the CFD Module
are described by the Openings
. Each opening is coupled to a single Node
(located in the middle of the opening), has a normal direction and a width.
Examples of networks can be found in the examples
folder.
C++
The simulation case is defined in main.cpp
. An example of a simulation case in c++ is given here:
#include <iostream>
#include <baseSimulator.h>
#include <baseSimulator.hh>
using T = double;
int main(int argc, char const* argv []) {
// New simulation object
std::cout << "[Main] Create simulation object..." << std::endl;
sim::Simulation<T> simulation = sim::Simulation<T>();
// Load and set the network from a JSON file
std::cout << "[Main] Load the JSON network..." << std::endl;
std::string file = "/path/to/Network.JSON";
arch::Network<T>* network = new arch::Network<T>(file);
simulation.setNetwork(network);
// Add Pressure and/or Flow Rate Pumps
std::cout << "[Main] Add pressure and Flow rate pumps..." << std::endl;
network->setPressurePump(0, T(1e3));
// Define and set the continuous phase fluid
std::cout << "[Main] Set the continuous phase fluid..." << std::endl;
sim::Fluid<T>* fluid = new sim::Fluid<T>(0, T(1000), T(1e-3));
fluid->setName("Water");
simulation.setContinuousPhase(fluid);
// Define and set the resistance model
std::cout << "[Main] Set the resistance model..." << std::endl;
sim::ResistanceModel1D<T>* resistanceModel = new sim::ResistanceModel1D<T>(fluid->getViscosity());
simulation.setResistanceModel(resistanceModel);
// Perform simulation and store results
std::cout << "[Main] Simulation..." << std::endl;
simulation.simulate();
// Print the results
std::cout << "[Main] Results..." << std::endl;
simulation.printResults();
return 0;
}
Python
The simulation case can be defined once the mmft.hybridsim
package is installed. An example for a simulation case in python is given here:
from mmft import hybridsim
# New simulation object
simulation = hybridsim.Simulation()
# Load and set the network from a JSON file
network = hybridsim.Network("/path/to/Network.JSON")
simulation.setNetwork(network)
# Add Pressure and/or Flow Rate Pumps
network.setPressurePump(0, 1e3)
# Define and set the continuous phase fluid
fluid = hybridsim.Fluid(0, 1000, 1e-3)
simulation.setContinuousPhase(fluid)
# Define and set the resistance model
resistanceModel = hybridsim.ResistanceModel(fluid.getViscosity())
simulation.setResistanceModel(resistanceModel)
# Perform simulation and store results
simulation.simulate()
# Print the results
simulation.print()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file mmft.hybridsim-0.1.1.tar.gz
.
File metadata
- Download URL: mmft.hybridsim-0.1.1.tar.gz
- Upload date:
- Size: 937.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99dec8658503f785916893edd3c653c345c7f01afaa71efe8545c2250fee54ee |
|
MD5 | 0cb180a1248c2059a5f19b4cfa9238c9 |
|
BLAKE2b-256 | 6a49a6f6179cfe47c6901e78df94183ec63f14b2b08c8a684541eb717214078c |
File details
Details for the file mmft.hybridsim-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: mmft.hybridsim-0.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 532.2 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8775551c62e0f2ea4544eb09332fe346a7702e88f04fd3f12699738a84b7e708 |
|
MD5 | 997bfa25c78bb3afc30a238d302f4af5 |
|
BLAKE2b-256 | d4b8df6f2a6b417cf54c775434d3546a3c59d13add635bffd3af8f8316a9a626 |
File details
Details for the file mmft.hybridsim-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: mmft.hybridsim-0.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 532.4 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6751a59e21bb8b8d62223b784d9986bd001885ed8d9ccc9912104ae423c076a |
|
MD5 | 3375ff959ffd8ca4e32d1252662c1061 |
|
BLAKE2b-256 | 4efd28d299562e18d2ea1588c92e03e70e02be3f575a79b6c8a261d162421078 |
File details
Details for the file mmft.hybridsim-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: mmft.hybridsim-0.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 532.8 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 178ab8aa807dad24649896f5be09f0f4a8fcd463ad219e528768b80c2c0a65de |
|
MD5 | 5296c5caf5221cef99fcdf19b773c3ae |
|
BLAKE2b-256 | c748e4966b316934198d6c8dfa4476904e246dbe2640d6408706b26eb9445711 |
File details
Details for the file mmft.hybridsim-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: mmft.hybridsim-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 532.4 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60bc5e4b6a8502d18908234e702c7c22bb1c838b6f7df9c3df09031ff9bf44a8 |
|
MD5 | 7de8831a23513b58fde5147d021743fd |
|
BLAKE2b-256 | 0a0e584766cddb7ff30d5c75128fb51e3515e66a85650b015a4a53044ca3f5bf |