Skip to main content

Materials Design via Mathematical Optimization

Project description

[!IMPORTANT] This is a standalone version adapted from the original implementation

MatOpt Logo

MatOpt (Materials Design via Mathematical Optimization) is an Algebraic Modeling Language (AML) system specifically design to create Pyomo objects for optimization-based nanomaterials design. MatOpt can be used to model crystalline nanostructured materials, including but not limited to particles, surfaces, and periodic bulk structures.

The main goals of this package are as follows:

  • To simplify the representation of nanostructured materials, streamlining the creation of materials optimization problems.
  • To automate many of the necessary steps of materials optimization, speeding up the development of new models and accelerating new materials discovery.
  • To provide a simple interface so that users do not need to handle the details of building efficient mathematical optimization models or the specific Pyomo syntax to do this.

If you are using MatOpt, please consider citing:

Basic Usage

There are two main sub-modules contained in the package serving two distinct purposes:

  • The matopt.materials module contains objects and methods for efficiently representing and manipulating a nanomaterial and its design space.
  • The matopt.aml module contains objects and methods for speeding up the casting of a pyomo model with simplified modeling syntax and automatic model formulation tools.

Dependencies

User access to the solver CPLEX through Pyomo is assumed. For users who do not have access to CPLEX, the use of NEOS-CPLEX is suggested as an alternative (Users need to setup a NEOS_EMAIL environment variable).

Define design canvas

Several pieces of information about the material and design space need to be specified in order to formulate a materials optimization problem. To fulfill this need, the matopt.materials module defines generic and simple objects for describing the type of material to be designed and its design space, also referred to as a "canvas".

Some key objects are listed as follows:

Build model via descriptors

The material type and design space specified provide indices, sets, and parameters for the optimization model. Using simple syntax, inspired by materials-related terminology, MatOpt users define a MatOptModel object, which will be translated into a Pyomo ConcreteModel object automatically.

MatOpt uses MaterialDescriptor objects to represent variables, constraints, and objectives. A MatOptModel object holds lists of MaterialDescriptor objects. By default, several universal site descriptors are pre-defined in the model.

Descriptor Explanation
Yik Presence of a building block of type k at site i
Yi Presence of any type of building block at site i
Xijkl Presence of a building block of type k at site i and a building block of type l at site j
Xij Presence of any building block at site i and any building block at site j
Cikl Count of neighbors of type l next to a building block of type k at site i
Ci Count of any type of neighbors next to a building block at site i

User-specified descriptors are defined by DescriptorRule objects in conjunction with Expr expression objects. Available expressions include:

Expression Explanation
LinearExpr Multiplication and addition of coefficients to distinct descriptors
SiteCombination Summation of site contributions from two sites
SumNeighborSites Summation of site contributions from all neighboring sites
SumNeighborBonds Summation of bond contributions to all neighboring sites
SumSites Summation across sites
SumBonds Summation across bonds
SumSiteTypes Summation across site types
SumBondTypes Summation across bond types
SumSitesAndTypes Summation across sites and site types
SumBondsAndTypes Summation across bonds and bond types
SumConfs Summation across conformation types
SumSitesAndConfs Summation across sites and conformation types

Several types of DescriptorRules are available.

Rule Explanation
LessThan Descriptor less than or equal to an expression
EqualTo Descriptor equal to an expression
GreaterThan Descriptor greater than or equal to an expression
FixedTo Descriptor fixed to a scalar value
PiecewiseLinear Descriptor equal to the evaluation of a piecewise linear function
Implies Indicator descriptor that imposes other constraints if equal to 1
NegImplies Indicator descriptor that imposes other constraints if equal to 0
ImpliesSiteCombination Indicator bond-indexed descriptor that imposes constraints on the two sites
ImpliesNeighbors Indicator site-indexed descriptor that imposes constraints on neighboring sites

From the combination of the above pre-defined descriptors, expressions, and rules, a user can specify a wide variety of other descriptors, as necessary.

Solve optimization model

Once the model is fully specified, the user can optimize it in light of a chosen descriptor to serve as the objective to be maximized or minimized, as appropriate. Several functions are provided for users to choose from. The results of the optimization process will be loaded into Design objects automatically. Users can then save material design(s) into files for further analysis and visualization using suitable functions provided. MatOpt provides interfaces to several standard crystal structure file formats, including CFG, PDB, POSCAR, and XYZ.

Examples

Below is a basic example of designing stable monometallic Pt nanoclusters given the size constraint. User can specify the problem using intuitive syntax and solve it using free NEOS-CPLEX solver (need to specify an email using NEOS_EMAIL environment variable)

import numpy as np
from math import sqrt
from matopt.materials.atom import Atom
from matopt.materials.lattices.fcc_lattice import FCCLattice
from matopt.materials.canvas import Canvas
from matopt.aml.expr import SumSites
from matopt.aml.rule import PiecewiseLinear, EqualTo
from matopt.aml.model import MatOptModel

Lat = FCCLattice(IAD=2.7704443686888935)
Canv = Canvas()
Canv.addLocation(np.array([0, 0, 0], dtype=float))
Canv.addShells(2, Lat.getNeighbors)
Canv.setNeighborsFromFunc(Lat.getNeighbors)
Atoms = [Atom("Pt")]

N = 22
m = MatOptModel(Canv, Atoms)
m.addSitesDescriptor(
    "CNRi",
    bounds=(0, sqrt(12)),
    integer=False,
    rules=PiecewiseLinear(
        values=[sqrt(CN) for CN in range(13)],
        breakpoints=[CN for CN in range(13)],
        input_desc=m.Ci,
        con_type="UB",
    ),
)
m.addGlobalDescriptor(
    "Ecoh", rules=EqualTo(SumSites(desc=m.CNRi, coefs=(1.0 / sqrt(12) * 1.0 / N)))
)
m.addGlobalDescriptor("Size", bounds=(N, N), rules=EqualTo(SumSites(desc=m.Yi)))

D = None
try:
    D = m.maximize(m.Ecoh, tilim=100, solver="neos-cplex")
except:
    print("MaOpt can not find usable solver (CPLEX or NEOS-CPLEX)")
if D is not None:
    D.toPDB("result.pdb")

For more usage cases and detailed explanation and walkthrough, please check the original repository. In each case, a Jupyter notebook with explanations as well as an equivalent Python script is provided.

Applications

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matopt-0.0.1.tar.gz (185.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matopt-0.0.1-py3-none-any.whl (81.8 kB view details)

Uploaded Python 3

File details

Details for the file matopt-0.0.1.tar.gz.

File metadata

  • Download URL: matopt-0.0.1.tar.gz
  • Upload date:
  • Size: 185.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.15

File hashes

Hashes for matopt-0.0.1.tar.gz
Algorithm Hash digest
SHA256 b37716b1001107ff95425e8dc43d5baa45f0503f625973993d3ae1c8d52619c5
MD5 ab0bf6e104d243b05cf856b0e82c9089
BLAKE2b-256 86346118e9d3423deb3cdb56bda50a8fa16a28e9f1e9c21e42a7a47367d2abd6

See more details on using hashes here.

File details

Details for the file matopt-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: matopt-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 81.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.15

File hashes

Hashes for matopt-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 983c67ab73c75e1ae803becd333535df369564f70e1f1d9edf0605e29b0f7c6f
MD5 104d94e786255d76eb86cec941928189
BLAKE2b-256 7b923f0d31fe2ddb987287ab48765c90b0c3bde0b805a2142d4cd5dbf8486c87

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page