Package: mmft.hybridsim
MMFT Hybrid SimulatorA Hybrid Simulator for Microfluidic Devices developed by theChair for Design Automationat theTechnical University of Munichas 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 visithttps://www.cda.cit.tum.de/research/microfluidics/.If you have any questions, feel free to contact us viamicrofluidics.cda@xcit.tum.deor by creating an issue on GitHub.System RequirementsThe 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.UsageC++To use this library, include the following code in your cmake file:include(FetchContent)FetchContent_Declare(hybridsimGIT_REPOSITORYhttps://github.com/cda-tum/mmft-hybrid-simulator.gitGIT_TAGmaster)FetchContent_MakeAvailable(hybridsim)target_link_libraries(${TARGET}PRIVATEhybridsim)and include the library API header in your project file:#include<baseSimulator.h>#include<baseSimulator.hh>PythonInstall the python packagepipinstallmmft.hybridsimand import the hybrid simulator in your codefrommmftimporthybridsimExampleTo use the hybrid simulator, the network must be defined in a Network.JSON file.
A network is defined as a set ofNodes,Channelsand CFDModules.ANodecontains 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}AChannelconnects 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 CFDModuleis 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 CFDModuleis described by a .STL file. The in-/outflow boundaries of the CFDModuleare described by theOpenings. Each opening is coupled to a singleNode(located in the middle of the opening), has a normal direction and a width.Examples of networks can be found in theexamplesfolder.C++The simulation case is defined inmain.cpp. An example of a simulation case in c++ is given here:#include<iostream>#include<baseSimulator.h>#include<baseSimulator.hh>usingT=double;intmain(intargc,charconst*argv[]){// New simulation objectstd::cout<<"[Main] Create simulation object..."<<std::endl;sim::Simulation<T>simulation=sim::Simulation<T>();// Load and set the network from a JSON filestd::cout<<"[Main] Load the JSON network..."<<std::endl;std::stringfile="/path/to/Network.JSON";arch::Network<T>*network=newarch::Network<T>(file);simulation.setNetwork(network);// Add Pressure and/or Flow Rate Pumpsstd::cout<<"[Main] Add pressure and Flow rate pumps..."<<std::endl;network->setPressurePump(0,T(1e3));// Define and set the continuous phase fluidstd::cout<<"[Main] Set the continuous phase fluid..."<<std::endl;sim::Fluid<T>*fluid=newsim::Fluid<T>(0,T(1000),T(1e-3));fluid->setName("Water");simulation.setContinuousPhase(fluid);// Define and set the resistance modelstd::cout<<"[Main] Set the resistance model..."<<std::endl;sim::ResistanceModel1D<T>*resistanceModel=newsim::ResistanceModel1D<T>(fluid->getViscosity());simulation.setResistanceModel(resistanceModel);// Perform simulation and store resultsstd::cout<<"[Main] Simulation..."<<std::endl;simulation.simulate();// Print the resultsstd::cout<<"[Main] Results..."<<std::endl;simulation.printResults();return0;}PythonThe simulation case can be defined once themmft.hybridsimpackage is installed. An example for a simulation case in python is given here:frommmftimporthybridsim# New simulation objectsimulation=hybridsim.Simulation()# Load and set the network from a JSON filenetwork=hybridsim.Network("/path/to/Network.JSON")simulation.setNetwork(network)# Add Pressure and/or Flow Rate Pumpsnetwork.setPressurePump(0,1e3)# Define and set the continuous phase fluidfluid=hybridsim.Fluid(0,1000,1e-3)simulation.setContinuousPhase(fluid)# Define and set the resistance modelresistanceModel=hybridsim.ResistanceModel(fluid.getViscosity())simulation.setResistanceModel(resistanceModel)# Perform simulation and store resultssimulation.simulate()# Print the resultssimulation.print()