gnnepcsaft-mcp-server 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of gnnepcsaft-mcp-server might be problematic. Click here for more details.

@@ -2,34 +2,43 @@
2
2
 
3
3
  from typing import Any, Callable, List
4
4
 
5
- from gnnepcsaft.data.rdkit_util import inchitosmiles, mw, smilestoinchi
6
- from gnnepcsaft.epcsaft.epcsaft_feos import (
7
- critical_points_feos,
8
- mix_den_feos,
9
- mix_vp_feos,
10
- pure_den_feos,
11
- pure_h_lv_feos,
12
- pure_vp_feos,
13
- )
14
5
  from mcp.server.fastmcp import FastMCP
15
6
 
16
- from .utils import mixture_phase, prediction, pubchem_description, pure_phase
7
+ from .utils import (
8
+ batch_convert_pure_density_to_kg_per_m3,
9
+ batch_critical_points,
10
+ batch_inchi_to_smiles,
11
+ batch_molecular_weights,
12
+ batch_pa_to_bar,
13
+ batch_predict_epcsaft_parameters,
14
+ batch_pure_density,
15
+ batch_pure_h_lv,
16
+ batch_pure_vapor_pressure,
17
+ batch_smiles_to_inchi,
18
+ mixture_density,
19
+ mixture_phase,
20
+ mixture_vapor_pressure,
21
+ pubchem_description,
22
+ pure_phase,
23
+ )
17
24
 
18
25
  mcp = FastMCP("gnnepcsaft")
19
26
  fn_list: List[Callable[..., Any]] = [
20
- pure_vp_feos,
21
- pure_den_feos,
22
- mix_den_feos,
23
- mix_vp_feos,
24
- pure_phase,
27
+ batch_convert_pure_density_to_kg_per_m3,
28
+ batch_critical_points,
29
+ batch_inchi_to_smiles,
30
+ batch_molecular_weights,
31
+ batch_pa_to_bar,
32
+ batch_predict_epcsaft_parameters,
33
+ batch_pure_density,
34
+ batch_pure_h_lv,
35
+ batch_pure_vapor_pressure,
36
+ batch_smiles_to_inchi,
37
+ mixture_density,
25
38
  mixture_phase,
39
+ mixture_vapor_pressure,
26
40
  pubchem_description,
27
- mw,
28
- smilestoinchi,
29
- prediction,
30
- inchitosmiles,
31
- pure_h_lv_feos,
32
- critical_points_feos,
41
+ pure_phase,
33
42
  ]
34
43
  for fn in fn_list:
35
44
  mcp.add_tool(fn)
@@ -2,14 +2,22 @@
2
2
 
3
3
  from json import loads
4
4
  from pathlib import Path
5
- from typing import List, Literal
5
+ from typing import List, Literal, Tuple
6
6
  from urllib.parse import quote
7
7
  from urllib.request import HTTPError, urlopen
8
8
 
9
9
  import numpy as np
10
10
  import onnxruntime as ort
11
11
  from gnnepcsaft.data.ogb_utils import smiles2graph
12
- from gnnepcsaft.data.rdkit_util import assoc_number, smilestoinchi
12
+ from gnnepcsaft.data.rdkit_util import assoc_number, inchitosmiles, mw, smilestoinchi
13
+ from gnnepcsaft.epcsaft.epcsaft_feos import (
14
+ critical_points_feos,
15
+ mix_den_feos,
16
+ mix_vp_feos,
17
+ pure_den_feos,
18
+ pure_h_lv_feos,
19
+ pure_vp_feos,
20
+ )
13
21
 
14
22
  file_dir = Path(__file__).parent
15
23
  model_dir = file_dir / "models"
@@ -19,11 +27,12 @@ msigmae_onnx = ort.InferenceSession(model_dir / "msigmae_7.onnx")
19
27
  assoc_onnx = ort.InferenceSession(model_dir / "assoc_8.onnx")
20
28
 
21
29
 
22
- def prediction(
30
+ def predict_epcsaft_parameters(
23
31
  smiles: str,
24
32
  ) -> List[float]:
25
33
  """Predict ePC-SAFT parameters
26
- `[m, sigma, epsilon/kB, kappa_ab, epsilon_ab/kB, dipole moment, na, nb]`
34
+ `[m, sigma, epsilon/kB, kappa_ab, epsilon_ab/kB, dipole moment, na, nb]` with
35
+ the GNNePCSAFT model.
27
36
 
28
37
  Args:
29
38
  smiles (str): SMILES of the molecule.
@@ -117,20 +126,203 @@ def mixture_phase(
117
126
  )
118
127
 
119
128
 
120
- def pubchem_description(inchi: str) -> str:
129
+ def pubchem_description(smiles: str) -> str:
121
130
  """
122
- Look for information on PubChem for the InChI.
131
+ Look for information on PubChem for the SMILES.
123
132
 
124
133
  Args:
125
- inchi (str): The InChI of the molecule.
134
+ smiles (str): The SMILES of the molecule.
126
135
  """
127
- url = (
128
- "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchi/description/json?inchi="
129
- + quote(inchi, safe="")
130
- )
136
+
131
137
  try:
138
+ inchi = smilestoinchi(smiles)
139
+ url = (
140
+ "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/inchi/description/json?inchi="
141
+ + quote(inchi, safe="")
142
+ )
132
143
  with urlopen(url) as ans:
133
144
  ans = loads(ans.read().decode("utf8").strip())
134
145
  except (TypeError, HTTPError, ValueError):
135
146
  ans = "no data available on this molecule in PubChem."
136
147
  return ans
148
+
149
+
150
+ def mixture_density(
151
+ parameters: List[List[float]],
152
+ state: List[float],
153
+ kij_matrix: List[List[float]],
154
+ ) -> float:
155
+ """Calculates mixture liquid density (mol/m³) with ePC-SAFT.
156
+
157
+ Args:
158
+ parameters: A list of
159
+ `[m, sigma, epsilon/kB, kappa_ab, epsilon_ab/kB, dipole moment, na, nb, MW]`
160
+ for each component of the mixture
161
+ state: A list with the state of the mixture
162
+ `[Temperature (K), Pressure (Pa), mole_fractions_1, mole_fractions_2, ...]`
163
+ kij_matrix: A matrix of binary interaction parameters
164
+ """
165
+
166
+ return mix_den_feos(parameters, state, kij_matrix)
167
+
168
+
169
+ def mixture_vapor_pressure(
170
+ parameters: List[List[float]],
171
+ state: List[float],
172
+ kij_matrix: List[List[float]],
173
+ ) -> Tuple[float, float]:
174
+ """Calculates mixture `(Bubble point (Pa), Dew point (Pa))` with ePC-SAFT.
175
+
176
+ Args:
177
+ parameters: A list of
178
+ `[m, sigma, epsilon/kB, kappa_ab, epsilon_ab/kB, dipole moment, na, nb, MW]`
179
+ for each component of the mixture
180
+ state: A list with the state of the mixture
181
+ `[Temperature (K), Pressure (Pa), mole_fractions_1, molefractions_2, ...]`.
182
+ The pressure should be any `float` value since it's not used in the calculation.
183
+ kij_matrix: A matrix of binary interaction parameters.
184
+ """
185
+
186
+ return mix_vp_feos(parameters, state, kij_matrix)
187
+
188
+
189
+ def batch_predict_epcsaft_parameters(
190
+ smiles: List[str],
191
+ ) -> List[List[float]]:
192
+ """Predict ePC-SAFT parameters
193
+ `[m, sigma, epsilon/kB, kappa_ab, epsilon_ab/kB, dipole moment, na, nb]`
194
+ for a list of SMILES with the GNNePCSAFT model.
195
+
196
+ Args:
197
+ smiles (List[str]): SMILES of the molecules.
198
+ """
199
+ return [predict_epcsaft_parameters(smi) for smi in smiles]
200
+
201
+
202
+ def batch_molecular_weights(
203
+ smiles: List[str],
204
+ ) -> List[float]:
205
+ """Calcultes molecular weight in `g/mol` for a list of SMILES
206
+
207
+ Args:
208
+ smiles (List[str]): SMILES of the molecules.
209
+ """
210
+ inchi_list = [smilestoinchi(smi) for smi in smiles]
211
+ return [mw(inchi) for inchi in inchi_list]
212
+
213
+
214
+ def batch_inchi_to_smiles(
215
+ inchi_list: List[str],
216
+ ) -> List[str]:
217
+ """Transform a list of InChI to SMILES.
218
+
219
+ Args:
220
+ inchi_list (List[str]): List of InChI
221
+ """
222
+ return [inchitosmiles(inchi) for inchi in inchi_list]
223
+
224
+
225
+ def batch_smiles_to_inchi(
226
+ smiles_list: List[str],
227
+ ) -> List[str]:
228
+ """Transform a list of SMILES to InChI.
229
+
230
+ Args:
231
+ smiles_list (List[str]): List of SMILES
232
+ """
233
+ return [smilestoinchi(smi) for smi in smiles_list]
234
+
235
+
236
+ def batch_pure_density(
237
+ smiles_list: List[str],
238
+ state: List[float],
239
+ ) -> List[float]:
240
+ """Calculates pure liquid density in `kg/m³` with ePC-SAFT for a list of SMILES.
241
+ The state is the same for all molecules. The GNNePCSAFT model is used to predict
242
+ ePCSAFT parameters.
243
+
244
+ Args:
245
+ smiles_list (List[str]): List of SMILES
246
+ state: A list with
247
+ `[Temperature (K), Pressure (Pa)]`
248
+ """
249
+ return [
250
+ pure_den_feos(predict_epcsaft_parameters(smi), state) for smi in smiles_list
251
+ ]
252
+
253
+
254
+ def batch_pure_vapor_pressure(
255
+ smiles_list: List[str],
256
+ temperature: float,
257
+ ) -> List[float]:
258
+ """Calculates pure vapor pressure in `Pa` with ePC-SAFT for a list of SMILES.
259
+ The temperature is the same for all molecules. The GNNePCSAFT model is used to predict
260
+ ePCSAFT parameters.
261
+
262
+ Args:
263
+ smiles_list (List[str]): List of SMILES
264
+ temperature: `Temperature (K)`
265
+ """
266
+ return [
267
+ pure_vp_feos(predict_epcsaft_parameters(smi), [temperature])
268
+ for smi in smiles_list
269
+ ]
270
+
271
+
272
+ def batch_pure_h_lv(
273
+ smiles_list: List[str],
274
+ temperature: float,
275
+ ) -> List[float]:
276
+ """Calculates pure liquid enthalpy of vaporization in `kJ/mol`
277
+ with ePC-SAFT for a list of SMILES.
278
+ The temperature is the same for all molecules.
279
+ The GNNePCSAFT model is used to predict
280
+ ePCSAFT parameters.
281
+
282
+ Args:
283
+ smiles_list (List[str]): List of SMILES
284
+ temperature: `Temperature (K)`
285
+ """
286
+ return [
287
+ pure_h_lv_feos(predict_epcsaft_parameters(smi), [temperature])
288
+ for smi in smiles_list
289
+ ]
290
+
291
+
292
+ def batch_critical_points(
293
+ smiles_list: List[str],
294
+ ) -> List[List[float]]:
295
+ """
296
+ Calculates critical points `[Temperature (K), Pressure (Pa), Density (mol/m³)]` with ePC-SAFT
297
+ for a list of SMILES. The GNNePCSAFT model is used to predict ePCSAFT parameters.
298
+
299
+ Args:
300
+ smiles_list (List[str]): List of SMILES
301
+ """
302
+ return [
303
+ critical_points_feos(predict_epcsaft_parameters(smi)) for smi in smiles_list
304
+ ]
305
+
306
+
307
+ def batch_pa_to_bar(
308
+ pressure_in_pa_list: List[float],
309
+ ) -> List[float]:
310
+ """Convert a list of pressure from `Pa` to `bar`.
311
+
312
+ Args:
313
+ pressure_in_pa_list (List[float]): List of pressure in `Pa`
314
+ """
315
+ return [pa / 100_000.0 for pa in pressure_in_pa_list]
316
+
317
+
318
+ def batch_convert_pure_density_to_kg_per_m3(
319
+ density_list: List[float],
320
+ molecular_weight_list: List[float],
321
+ ) -> List[float]:
322
+ """Convert a list of density from `mol/m³` to `kg/m³`
323
+
324
+ Args:
325
+ density_list (List[float]): List of density in `mol/m³`
326
+ molecular_weight_list (List[float]): List of molecular weight in `g/mol`
327
+ """
328
+ return [den * molw / 1000 for den, molw in zip(density_list, molecular_weight_list)]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: gnnepcsaft-mcp-server
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: Model Context Protocol server for GNNePCSAFT tools
5
5
  License: GNU General Public License v3.0
6
6
  Author: wildsonbbl
@@ -1,12 +1,12 @@
1
1
  gnnepcsaft_mcp_server/__init__.py,sha256=Npbt9RPLtKrFDK-oeyrAbz0b7lg9Y1Le1mxAQVtD_PY,24
2
- gnnepcsaft_mcp_server/mcp_server.py,sha256=W-W-C8f2Na7Z6UKFipnrqZlsOkiUkjUve_I4OIra33Q,820
2
+ gnnepcsaft_mcp_server/mcp_server.py,sha256=XUM9ir7RvJA8npgIlo7n8J1ZhnQzDslGnsxwOnItbEo,1085
3
3
  gnnepcsaft_mcp_server/models/.gitignore,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  gnnepcsaft_mcp_server/models/assoc_8.onnx,sha256=FBSU3cP1NyelkwCtLaWVhaeX8QuzQGp6Mf3lSV97mzE,2287889
5
5
  gnnepcsaft_mcp_server/models/assoc_8.onnx.data,sha256=AMg5VrBZi1F-kZ_YAQay_BDaQQtbs8ihfn4BgWbYzeM,11468800
6
6
  gnnepcsaft_mcp_server/models/msigmae_7.onnx,sha256=TiKHrwBbNPyoOeeRQ_W_xnEqEtopmI_FIBtZJyN4afk,2288073
7
7
  gnnepcsaft_mcp_server/models/msigmae_7.onnx.data,sha256=kExPbT75jMLRAYRQQZ8WPeY0rYvAfDZx-Bnji_dLJ1s,11469056
8
- gnnepcsaft_mcp_server/utils.py,sha256=Be62JR9tfJiCP3BOaRExGcetu1Q3xoFAps6r_JXw0nM,4288
9
- gnnepcsaft_mcp_server-0.1.1.dist-info/METADATA,sha256=sHhC1mq3oNsZDGR4Au0RAWmjOT4wmBk9THiOVlfo3wg,1653
10
- gnnepcsaft_mcp_server-0.1.1.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
11
- gnnepcsaft_mcp_server-0.1.1.dist-info/entry_points.txt,sha256=5tsnxZG8Vtdrr3CT-8Pv35RjpcDiR0L28cYxxHeCsPI,70
12
- gnnepcsaft_mcp_server-0.1.1.dist-info/RECORD,,
8
+ gnnepcsaft_mcp_server/utils.py,sha256=6NJ5lB4q-EjC1KXBKXXBPQ4qtVCZcjvR82I2lD06hIk,9916
9
+ gnnepcsaft_mcp_server-0.1.2.dist-info/METADATA,sha256=juIntwbiIW1lwI5vTYLl7QcGUXCkCBlcf8ffKVDSCAU,1653
10
+ gnnepcsaft_mcp_server-0.1.2.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
11
+ gnnepcsaft_mcp_server-0.1.2.dist-info/entry_points.txt,sha256=5tsnxZG8Vtdrr3CT-8Pv35RjpcDiR0L28cYxxHeCsPI,70
12
+ gnnepcsaft_mcp_server-0.1.2.dist-info/RECORD,,