3 个不稳定版本
0.2.1 | 2024 年 6 月 28 日 |
---|---|
0.2.0 | 2024 年 4 月 29 日 |
0.1.0 | 2022 年 10 月 19 日 |
#98 在 科学
每月 23 次下载
195KB
5K SLoC
FeOs-CAMPD
基于 FeOs
框架的计算机辅助分子和工艺设计。
该软件包提供执行计算机辅助分子和工艺设计的基础设施。它包括
- NLP/MIQCP 求解器绑定 (Artelys Knitro)
- 实现自定义的外部近似算法以解决结果 MINLP
- 分子表示(组计数(CoMT-CAMD)和分子超结构)
- 属性模型(PC-SAFT 和(异段)gc-PC-SAFT)
以及用于为任意工艺模型运行优化问题的框架。该框架是用 Rust 实现的,可以直接访问或通过 Python 接口访问。
目前,仅通过安装 Artelys Knitro 12 才能解决 CAMPD 问题。非常希望转向开源实现,但由于时间限制,目前尚未立即计划。如果您有兴趣做出贡献,请联系维护者。
安装
Rust
只需将依赖项添加到您的 Cargo.toml
feos-campd = "0.2"
Python
如果您已安装 Rust 编译器,可以使用以下命令直接从源代码构建软件包:
pip install git+https://github.com/feos-org/feos-campd
用法
以下部分展示了在 Python 中使用该框架的方法。在 Rust 和 Python 的语言边界内,API 尽可能保持一致。因此,Rust 中实现的步骤与 API 详细信息相同。有关 API 详细信息,请参阅 文档。
分子表示
# define the molecular representation using a molecule superstructure
molecule = SuperMolecule.alkane(size)
# or a combination of superstructures
molecule = SuperMolecule.non_associating(size)
# or provide a list of molecules to choose from
molecule = CoMTCAMD.from_molecules(list_of_identifiers)
molecule = CoMTCAMD.from_json_molecules(list_of_identifiers)
# or provide an input file with group and structure definitions for CoMT-CAMD
molecule = CoMTCAMD.from_json(list_of_identifiers)
属性模型
# The available property models are compatible with the parameter files in FeOs
property_model = GcPcSaftPropertyModel.from_json([molecule], "sauer2014_hetero.json", "joback1987.json")
property_model = PcSaftPropertyModel.from_json_molecules("gross2001.json", "poling2000.json")
property_model = PcSaftPropertyModel.from_json_groups("sauer2014_homo.json", "joback1987.json")
工艺模型
#To implement a process model in Python, define a class with the following methods:
class ORC:
# For each process variable: the lower bound, the upper bound, and the initial value
def variables(self):
return [[lb_0, ub_0, init_0], [lb_1, ub_1, init_1], ...]
# The number of equality constraints (h(x) = 0)
def equality_constraints(self):
return ...
# The number of inequality constraints (g(x) >= 0)
def inequality_constraints(self):
return ...
# For given equation of state and process variables x, return the target, and the values of
# equality and inequality constraints
def solve(self, eos, x):
# eos - the equation of state object as used in FeOs, e.g.,
state = State(eos, temperature=300*KELVIN, pressure=BAR)
# x - the list of process degrees of freedom, e.g.,
T_in, p_des, ... = x
# The function is called with regular Python data types (floats), so the implementation
# of the process model can be as flexible as desired and involve external function calls
...
return target, equality_constraints, inequality_constraints
优化问题
# combine molecular representation, property model, and process model in an optimization problem
# for a pure component
problem = OptimizationProblem.pure(molecule, property_model, process)
# or a binary mixture
problem = OptimizationProblem.pure([molecule1, molecule2], property_model, process)
# use either of these algorithms
# (The boolean indicates whether the algorithm should update the lower bound of the outer approximation
# True can lead to local optima in non-convex problems)
algorithm = OuterApproximationAlgorithm.DuranGrossmann(True)
algorithm = OuterApproximationAlgorithm.DuranGrossmann(False)
algorithm = OuterApproximationAlgorithm.FletcherLeyffer
# to determine a ranking of the optimal molecules
problem.outer_approximation_ranking(y0, algorithm, num_molecules, "options_NLP.opt", "options_MILP.opt")
分子表示和属性模型可以按照以下方式组合
PC-SAFT | gc-PC-SAFT | |
---|---|---|
CoMTCAMD | 是 | 否 |
SuperMolecule | 是 | 是 |
引用我们
如果您认为 FeOs-torch 对您自己的研究有所帮助,请考虑引用我们的 出版物,这是本库的来源。
@article{rehner2023molecule_superstructures,
author = {Rehner, Philipp and Schilling, Johannes and Bardow, André},
title = {Molecule superstructures for computer-aided molecular and process design}
journal = {Molecular Systems Design & Engineering},
volume = {8},
issue = {4},
number = {12},
pages = {488-499},
year = {2023}
}
依赖项
~17–25MB
~284K SLoC