Abstract
Soft materials underpin many domains of science and engineering, including soft robotics, structured fluids, and biological and particulate media. In response to applied mechanical, electromagnetic or chemical stimuli, such materials typically change shape, often dramatically. Predicting their structure is of great interest to facilitate design and mechanistic understanding, and can be cast as an optimization problem where a given energy function describing the physics of the material is minimized with respect to the shape of the domain and additional fields. However, shape-optimization problems are very challenging to solve, and there is a lack of suitable simulation tools that are both readily accessible and general in purpose. Here we present an open-source programmable environment, Morpho, and demonstrate its versatility by showcasing a range of applications from different areas of soft-matter physics: swelling hydrogels, complex fluids that form aspherical droplets, soap films and membranes, and filaments.
This is a preview of subscription content, access via your institution
Access options
Access Nature and 54 other Nature Portfolio journals
Get Nature+, our best-value online-access subscription
$29.99 /Â 30Â days
cancel any time
Subscribe to this journal
Receive 12 digital issues and online access to articles
$99.00 per year
only $8.25 per issue
Buy this article
- Purchase on SpringerLink
- Instant access to full article PDF
Prices may be subject to local taxes which are calculated during checkout
Similar content being viewed by others
Data availability
All data were generated by Morpho from input scripts provided in a separate repository at https://doi.org/10.5281/zenodo.14193815 (ref. 83). Source data are provided with this paper.
Code availability
The Morpho code used for this study is archived with Zenodo at https://doi.org/10.5281/zenodo.14179515 (ref. 43). Updated versions will be available from GitHub at https://github.com/Morpho-lang/morpho. Source code for all examples shown in this publication is provided in a separate repository at https://doi.org/10.5281/zenodo.14193814 (ref. 83). All code is released under an open-source MIT license.
References
Wehner, M. et al. An integrated design and fabrication strategy for entirely soft, autonomous robots. Nature 536, 451â455 (2016).
Shah, D. S. et al. A soft robot that adapts to environments through shape change. Nat. Mach. Intell. 3, 51â59 (2021).
Khanra, A. et al. Controlling the shape and topology of two-component colloidal membranes. Proc. Natl Acad. Sci. USA 119, e2204453119 (2022).
Safdari, M., Zandi, R. & van der Schoot, P. Effect of electric fields on the director field and shape of nematic tactoids. Phys. Rev. E 103, 062703 (2021).
Ferris, A. J., Rosenblatt, C. & Atherton, T. J. Spontaneous anchoring-mediated topography of an orientable fluid. Phys. Rev. Lett. 126, 057803 (2021).
Cousins, J. R., Duffy, B. R., Wilson, S. K. & Mottram, N. J. Young and YoungâLaplace equations for a static ridge of nematic liquid crystal, and transitions between equilibrium states. Proc. R. Soc. A 478, 20210849 (2022).
Silverberg, J. L. et al. Using origami design principles to fold reprogrammable mechanical metamaterials. Science 345, 647â650 (2014).
Paulose, J., Chen, B. G.-g. & Vitelli, V. Topological modes bound to dislocations in mechanical metamaterials. Nat. Phys. 11, 153â156 (2015).
Goodman-Strauss, C. & Sullivan, J. M. in Discrete Geometry (ed. Bezdek, A.) Ch. 22 (Marcel Dekker, 2003).
Sydney Gladman, A., Matsumoto, E. A., Nuzzo, R. G., Mahadevan, L. & Lewis, J. A. Biomimetic 4D printing. Nat. Mater. 15, 413â418 (2016).
Na, J.-H. et al. Programming reversibly self-folding origami with micropatterned photo-crosslinkable polymer trilayers. Adv. Mater. 27, 79â85 (2015).
Jensen, K. E. et al. Wetting and phase separation in soft adhesion. Proc. Natl Acad. Sci. USA 112, 14490â14494 (2015).
Datta, S. S., Preska Steinberg, A. & Ismagilov, R. F. Polymers in the gut compress the colonic mucus hydrogel. Proc. Natl Acad. Sci. USA 113, 7041â7046 (2016).
Xie, Z. & Atherton, T. J. Jamming on convex deformable surfaces. Soft Matter 20, 1070â1078 (2024).
Keber, F. C. et al. Topology and dynamics of active nematic vesicles. Science 345, 1135â1139 (2014).
Peterson, M. S. E., Baskaran, A. & Hagan, M. F. Vesicle shape transformations driven by confined active filaments. Nat. Commun. 12, 7247 (2021).
Hoffmann, L. A., Carenza, L. N., Eckert, J. & Giomi, L. Theory of defect-mediated morphogenesis. Sci. Adv. 8, eabk2712 (2022).
Hawkes, E. et al. Programmable matter by folding. Proc. Natl Acad. Sci. USA 107, 12441â12445 (2010).
Sethian, J. A. Level Set Methods and Fast Marching Methods: Evolving Interfaces in Computational Geometry, Fluid Mechanics, Computer Vision and Materials Sciences (Cambridge Univ. Press, 2010).
Provatas, N. & Elder, K. Phase-Field Methods in Materials Science and Engineering (Wiley, 2010).
Brakke, K. A. The surface evolver. Exp. Math. 1, 141â165 (1992).
Brakke, K. A., Klinowski, J. & Mackay, A. L. The Surface Evolver and the stability of liquid surfaces. Philos. Trans. R. Soc. Lond. A 354, 2143â2157 (1996).
Barrata, I. A. et al. DOLFINx: the next generation FEniCS problem solving environment. Zenodo https://zenodo.org/records/10447666 (2023).
Rathgeber, F. et al. Firedrake: automating the finite element method by composing abstractions. ACM Trans. Math. Softw. 43, 1â27 (2016).
Laurain, A. A level set-based structural optimization code using fenics. Struct. Multidisc. Optim. 58, 1311â1334 (2018).
Paganini, A. & Wechsung, F. Fireshape: a shape optimization toolbox for firedrake. Struct. Multidisc. Optim. 63, 2553â2569 (2021).
Rozvany, G. I. A critical review of established methods of structural topology optimization. Struct. Multidisc. Optim. 37, 217â237 (2009).
Sigmund, O. A 99 line topology optimization code written in Matlab. Struct. Multidisc. Optim. 21, 120â127 (2001).
Mohammadi, B. & Pironneau, O. Shape optimization in fluid mechanics. Annu. Rev. Fluid Mech. 36, 255â279 (2004).
Mittal, R. & Iaccarino, G. Immersed boundary methods. Annu. Rev. Fluid Mech. 37, 239â261 (2005).
Evans, L. C. Partial Differential Equations Vol. 19 (American Mathematical Society, 2022).
Walker, S. W. The Shapes of Things: A Practical Guide to Differential Geometry and the Shape Derivative (SIAM, 2015).
Susanne, C., Brenner, L. & Scott, L. The Mathematical Theory of Finite Element Methods Vol. 15 (Springer, 1994).
Canham, P. B. The minimum energy of bending as a possible explanation of the biconcave shape of the human red blood cell. J. Theor. Biol. 26, 61â81 (1970).
Helfrich, W. Elastic properties of lipid bilayers: theory and possible experiments. Z. Naturforsch. C 28, 693â703 (1973).
Kamien, R. D. The geometry of soft materials: a primer. Rev. Mod. Phys. 74, 953â971 (2002).
Nelson, D., Piran, T. & Weinberg, S. Statistical Mechanics of Membranes and Surfaces 2nd edn (World Scientific, 2004).
Powers, T. R., Huber, G. & Goldstein, R. E. Fluid-membrane tethers: minimal surfaces and elastic boundary layers. Phys. Rev. E 65, 041901 (2002).
de Gennes, P. G. & Prost, J. The Physics of Liquid Crystals (Clarendon Press, 1993).
Lagerwall, J. P. & Scalia, G. A new era for liquid crystal research: applications of liquid crystals in soft matter nano-, bio- and microtechnology. Curr. Appl. Phys. 12, 1387â1412 (2012).
Prinsen, P. & van der Schoot, P. Shape and director-field transformation of tactoids. Phys. Rev. E 68, 021701 (2003).
Mottram, N. J. & Newton, C. J. P. Introduction to Q-tensor theory. Preprint at https://arxiv.org/abs/1409.3542 (2014).
Atherton, T. et al. Morpho-lang/morpho: v0.6.1. Zenodo https://doi.org/10.5281/zenodo.14179515 (2024).
Adler, J. H., Andrei, A. S. & Atherton, T. J. Nonlinear methods for shape optimization problems in liquid crystal tactoids. Preprint at https://arxiv.org/abs/2310.04022 (2023).
Ahmed, E. M. Hydrogel: preparation, characterization and applications: a review. J. Adv. Res. 6, 105â121 (2015).
Bertrand, T., Peixinho, J., Mukhopadhyay, S. & MacMinn, C. W. Dynamics of swelling and drying in a spherical gel. Phys. Rev. Appl. 6, 064010 (2016).
Azzam, R. A. Polymeric conditioner gels for desert soils. Commun. Soil Sci. Plant Anal. 14, 739â760 (1983).
Wei, Y. & Durian, D. J. Effect of hydrogel particle additives on water-accessible pore structure of sandy soils: a custom pressure plate apparatus and capillary bundle model. Phys. Rev. E 87, 053013 (2013).
Kang, M. K. & Huang, R. A variational approach and finite element implementation for swelling of polymeric hydrogels under geometric constraints. J. Appl. Mech. 77, 061004 (2010).
Louf, J.-F., Lu, N. B., OâConnell, M. G., Cho, H. J. & Datta, S. S. Under pressure: hydrogel swelling in a granular medium. Sci. Adv. 7, eabd2711 (2021).
Joshi, C., Giso, M. Q., Louf, J.-F., Datta, S. S. & Atherton, T. J. An energy-optimization method to study gel-swelling in confinement. Soft Matter 19, 7184â7191 (2023).
Quesada-Pérez, M., Maroto-Centeno, J. A., Forcada, J. & Hidalgo-Alvarez, R. Gel swelling theories: the classical formalism and recent approaches. Soft Matter 7, 10536 (2011).
Plummer, A., Adkins, C., Louf, J.-F., KoÅ¡mrlj, A. & Datta, S. S. Obstructed swelling and fracture of hydrogels. Soft Matter 20, 1425â1437 (2024).
Swigon, D., Coleman, B. D. & Tobias, I. The elastic rod model for DNA and its application to the tertiary structure of DNA minicircles in mononucleosomes. Biophys. J. 74, 2515â2530 (1998).
Plumb-Reyes, T. B., Charles, N. & Mahadevan, L. Combing a double helix. Soft Matter 18, 2767â2775 (2022).
Prasath, S. G., Marthelot, J., Govindarajan, R. & Menon, N. Shapes of a filament on the surface of a bubble. Proc. R. Soc. A 477, 20210353 (2021).
Gibou, F., Fedkiw, R. & Osher, S. A review of level-set methods and some recent applications. J. Comput. Phys. 353, 82â109 (2018).
Zhao, H.-K., Merriman, B., Osher, S. & Wang, L. Capturing the behavior of bubbles and drops using the variational level set approach. J. Comput. Phys. 143, 495â518 (1998).
Kang, M., Merriman, B. & Osher, S. Numerical simulations for the motion of soap bubbles using level set methods. Comput. Fluids 37, 524â535 (2008).
Howard, A. A. & Tartakovsky, A. M. A conservative level set method for N-phase flows with a free-energy-based surface tension model. J. Comput. Phys. 426, 109955 (2021).
Osher, S. & Fedkiw, R. P. Level set methods: an overview and some recent results. J. Comput. Phys. 169, 463â502 (2001).
Blackford, L. S. et al. An updated set of basic linear algebra subprograms (BLAS). ACM Trans. Math. Softw. 28, 135â151 (2002).
Anderson, E. et al. LAPACK Usersâ Guide (SIAM, 1999).
Davis, T. A. Direct Methods for Sparse Linear Systems (SIAM, 2006).
Xing, X. et al. Morphology of nematic and smectic vesicles. Proc. Natl Acad. Sci. USA 109, 5202â5206 (2012).
Giomi, L. & Desimone, A. Spontaneous division and motility in active nematic droplets. Phys. Rev. Lett. 112, 147802 (2014).
Maroudas-Sacks, Y. et al. Topological defects in the nematic order of actin fibers as organization centers of hydra morphogenesis. Nat. Phys. 17, 251â259 (2020).
Nystrom, R. Crafting Interpreters (Genever Benning, 2021).
Anderson, E. et al. LAPACK Usersâ Guide 3rd edn (Society for Industrial and Applied Mathematics, 1999).
Nocedal, J. & Wright, S. J. Numerical Optimization (Springer, 1999).
Boyd, S., Boyd, S. P. & Vandenberghe, L. Convex Optimization (Cambridge Univ. Press, 2004).
Dalcin, L. D., Paz, R. R., Kler, P. A. & Cosimo, A. Parallel distributed computing using Python. Adv. Water Resour. 34, 1124â1139 (2011).
Balay, S. et al. PETSc: portable, extensible toolkit for scientific computation. Astrophysics Source Code Library ascl:2210.016 (2022).
Emerson, D. B., Farrell, P. E., Adler, J. H., MacLachlan, S. P. & Atherton, T. J. Computing equilibrium states of cholesteric liquid crystals in elliptical channels with deflation algorithms. Liq. Cryst. 45, 341â350 (2018).
Persistence of Vision Raytracer [computer software] (Persistence of Vision Raytracer, 2004); http://www.povray.org/
Crane, K. Discrete Differential Geometry: An Applied Introduction Notices of the AMS, Communication (CMU School of Computer Science, 2018).
Fernandez-Nieves, A. Microgel Suspensions: Fundamentals and Applications (Wiley, 2011).
Flory, P. J. & Rehner, J. Statistical mechanics of cross-linked polymer networks I. Rubberlike elasticity. J. Chem. Phys. 11, 512â520 (1943).
Flory, P. J. & Rehner, J. Statistical mechanics of cross-linked polymer networks II. Swelling. J. Chem. Phys. 11, 521â526 (1943).
Hong, W., Zhao, X., Zhou, J. & Suo, Z. A theory of coupled diffusion and large deformation in polymeric gels. J. Mech. Phys. Solids 56, 1779â1793 (2008).
Rognes, M. E., Calderer, M.-C. & Micek, C. A. Modelling of and mixed finite element methods for gels in biomedical applications. SIAM J. Appl. Math. 70, 1305â1329 (2009).
Sussman, M., Smereka, P. & Osher, S. A level set approach for computing solutions to incompressible two-phase flow. J. Comput. Phys. 114, 146â159 (1994).
Atherton, T. Morpho-lang/morpho-paper: v1.0. Zenodo https://doi.org/10.5281/zenodo.14193815 (2024).
Acknowledgements
This material is based on work supported by the National Science Foundation under grant no. ACI-2003820. The funders had no role in study design, data collection and analysis, decision to publish or preparation of the manuscript. T.J.A. thanks the many people who have used various versions of the program or otherwise contributed to the project: C. Moseley, K. Vohra, P. Navarro, H. Ramirez, R. Ong, S. Wufeng, A. Wilson, A. Culbert, A. DeBenedictis, B. Mbanga, C. Burke, I. Hunter, M. Giso, M. S. E. Peterson, Z. Xie, J. E. Flores-Calderón and students from the Tufts Computational Physics course who patiently tried early versions of the code.
Author information
Authors and Affiliations
Contributions
T.J.A. designed the overall architecture for the Morpho code. T.J.A., C.J. and D.H. contributed to implementation. A.S.A., S.H. and J.H.A. advised on optimization algorithms. C.W. and E.D. developed the tactoid analysis example. E.H. devised the tubule pulling example. C.J. developed the filament and hydrogel examples. All authors prepared the paper.
Corresponding author
Ethics declarations
Competing interests
The authors declare no competing interests.
Peer review
Peer review information
Nature Computational Science thanks the anonymous reviewer(s) for their contribution to the peer review of this work. Primary Handling Editor: Jie Pan, in collaboration with the Nature Computational Science team.
Additional information
Publisherâs note Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Supplementary information
Supplementary Video 1
Membrane tether at increasing indentation.
Supplementary Video 2
Swelling hydrogel bead between confining spheres.
Supplementary Video 3
Coiling transition of an elastic filament confined to a curved surface.
Supplementary Video 4
Two-dimensional minimal surface problem solved by a level-set method with finite differences.
Supplementary Video 5
Two-dimensional minimal surface problem solved by a variational level-set method.
Source data
Source Data Fig. 1
Statistical source data.
Source Data Fig. 2
Statistical source data.
Source Data Fig. 3
Statistical source data.
Source Data Fig. 4
Statistical source data.
Source Data Fig. 5
Statistical source data.
Rights and permissions
Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.
About this article
Cite this article
Joshi, C., Hellstein, D., Wennerholm, C. et al. A programmable environment for shape optimization and shapeshifting problems. Nat Comput Sci (2024). https://doi.org/10.1038/s43588-024-00749-7
Received:
Accepted:
Published:
DOI: https://doi.org/10.1038/s43588-024-00749-7