Skip to content

Python implementation of the Manifold microfluidic simulation language

License

Notifications You must be signed in to change notification settings

manifold-lang/pymanifold

Repository files navigation

pymanifold

Build Status CircleCI build status

Python implementation of the Manifold microfluidic simulation language

This library allows you to design a microfluidic circuit as a schematic consisting of:

  • Nodes - consist of elementary devices such as logic gates or fluid input channels
  • Connections - connect two nodes together
  • Ports - a type of node that allows for the input or output of fluids
  • Constraints - describe design rules or goals that are too complex to be described in terms of the other three primitives

Once the circuit has been designed you can call solve on the schematic which will use a Satisfiability Modulo Theory (SMT) solver to determine if the given design and parameters has a solution (meaning that the circuit will work) and if so, provide the range of parameters (dimensions of the connections, flow rates, pressures, etc.) that the circuit will remain functional

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Installing

This can be installed within Python 3 using pip install --user pymanifold However this will require building dReal4 from source and installing OMPython from GitHub along with OpenModelica if you need electrical simulations, alternatively we provide a Docker image which contains all of these libraries baked in. You can get the docker image by running:

docker pull jsreid13/pymanifold:latest 

Run the single_channel_test,py script within this image using:

docker container run -it --rm -v $(pwd):/tmp -v $(pwd)/src:/tmp/src -w /tmp -e PYTHONPATH=/tmp jsreid13/pymanifold python3 tests/t_junction_test.py

Note: You need to run this command in your terminal while in the root of this repository

Any script within this repo can be run using this command, to run your own script you need to change the directory that you run this command from within your terminal to the directory containing that script and change tests/single_channel_test.py to the name of your script

Usage

The code to create a simple T-Junction droplet generator is as follows found in this test script, but is still in development:

import src.pymanifold as pymf

sch = pymf.Schematic([0, 0, 1, 1])
#       D
#       |
#   C---N---O
continuous_node = 'continuous'
dispersed_node = 'dispersed'
output_node = 'out'
junction_node = 't_j'

# Continuous and output node should have same flow rate
# syntax: sch.port(name, design[, pressure, flow_rate, density, X_pos, Y_pos])
sch.port(continuous_node, kind='input', fluid_name='mineraloil')
sch.port(dispersed_node, kind='input', fluid_name='water')
sch.port(output_node, kind='output')

# syntax: sch.node(name, X_pos, Y_pos, kind='node')
sch.node(junction_node, kind='tjunc')

# syntax: sch.channel(shape, min_length, width, height, input, output)
sch.channel(junction_node, output_node, min_height=0.0002, min_width=0.00021, phase='output')
sch.channel(continuous_node, junction_node, min_height=0.0002, min_width=0.00021, phase='continuous')
sch.channel(dispersed_node, junction_node, min_height=0.0002, min_width=0.00021, phase='dispersed')

print(sch.solve())

Output:
continuous_viscosity : [0.0003050999999999999893, 0.0003050999999999999893]
continuous_pressure : [500.2152984093409032, 501.8325784839180415]
continuous_flow_rate : [4.696753629886489994e-08, 4.704340199341540629e-08]
continuous_density : [800, 800]
continuous_x : [0.9999999995343387127, 1]
continuous_y : [0, 4.635954403007642003e-11]
dispersed_viscosity : [0.001000000000000000021, 0.001000000000000000021]
dispersed_pressure : [984782.4393873409135, 984784.0566674155416]
dispersed_flow_rate : [1.864071931417897898e-06, 1.864073462073317849e-06]
dispersed_density : [999.8700000000000045, 999.8700000000000045]
dispersed_x : [0.9999999995343387127, 1]
dispersed_y : [0, 4.635954403007642003e-11]
out_viscosity : [0.0003050999999999999893, 0.0003050999999999999893]
out_pressure : [983856.6639627817785, 983858.2812428564066]
out_flow_rate : [1.911039467716762791e-06, 1.911116864066733473e-06]
out_density : [999.8700000000000045, 999.8700000000000045]
out_x : [0.9999999995343387127, 1]
out_y : [0, 4.635954403007642003e-11]
t_j_pressure : [984373.6733107801992, 984375.2905908548273]
t_j_flow_rate : [1.911039467716762791e-06, 1.911116864066733473e-06]
t_j_viscosity : [65.62503437499998427, 68.75003124999999216]
t_j_density : [999.8700000000000045, 999.8700000000000045]
t_j_x : [0.9999999995343387127, 1]
t_j_y : [8.849630305854020956e-10, 9.313225746154785156e-10]
t_j_out_length : [1.000000000000000269e-09, 1.041250292910165269e-09]
t_j_out_width : [0.0002100000000000000087, 0.0002100000000000000087]
t_j_out_height : [0.0002000000000000000096, 0.0002000000000000000096]
t_j_out_flow_rate : [1.911039467716762791e-06, 1.911116864066733473e-06]
t_j_out_droplet_volume : [4.054812791117536518e-10, 4.061243617092562122e-10]
t_j_out_viscosity : [65.62503437499998427, 68.75003124999999216]
t_j_out_resistance : [270538289.0999316573, 270538292.8252219558]
continuous_t_j_length : [1.000000000000000269e-09, 1.041250292910165269e-09]
continuous_t_j_width : [0.0002100000000000000087, 0.0002100000000000000087]
continuous_t_j_height : [0.0002000000000000000096, 0.0002000000000000000096]
continuous_t_j_flow_rate : [4.696753629886489994e-08, 4.704340199341540629e-08]
continuous_t_j_viscosity : [0.0003050999999999999893, 0.0003050999999999999893]
continuous_t_j_resistance : [588836707.1747778654, 588836709.0374230146]
dispersed_t_j_length : [1.000000000000000269e-09, 1.041250292910165269e-09]
dispersed_t_j_width : [0.0002100000000000000087, 0.0002100000000000000087]
dispersed_t_j_height : [0.0002000000000000000096, 0.0002000000000000000096]
dispersed_t_j_flow_rate : [1.864071931417897898e-06, 1.864073462073317849e-06]
dispersed_t_j_viscosity : [0.001000000000000000021, 0.001000000000000000021]
dispersed_t_j_resistance : [473663290.9625768065, 473663292.8252219558]
epsilon : [2.099999999999999799e-06, 2.100000000000000223e-06]
epsilon : [2.099999999999999799e-06, 2.100000000000000223e-06]

Development

This project is still in development, features that need to be added are:

  • Create models of more components in Modelica to simulate in MapleSim
  • Create a website to outline usage using read the docs
    • Fill in the content to match other readthedocs like pysmt or Jupyter

Authors

  • Josh Reid - Creator of Python implementation - jsreid13
  • Murphy Berzish - Creator of Manifold - mtrberzi
  • Derek Rayside - Owner of Manifold - drayside
  • Chris Willar - Contributor to Manifold - cwillgit
  • Shubham Verma - Contributor to Manifold - VermaSh
  • Yifan Mo - Contributor to Manifold - ymo13
  • Devika Khosla - Contributor to Manifold - DevikaKhosla
  • Ali Abdullah - Contributor to Manifold - ali-abdullah
  • Tyson Andre - Contributor to Manifold - TysonAndre
  • Max Chen - Contributor to Manifold - maxqchen
  • Nik Klassen - Contributor to Manifold - nikklassen
  • Peter Socha - Contributor to Manifold - psocha

License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details

About

Python implementation of the Manifold microfluidic simulation language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published