MPh-py / MPh

Pythonic scripting interface for Comsol Multiphysics
https://mph.readthedocs.io
MIT License
274 stars 70 forks source link

Evaluation error when dataset has slash in name #66

Closed byquip closed 2 years ago

byquip commented 2 years ago

Hello, I was trying to retrieve some data from my .mph project but got error which I have no idea how to handle. Is there way to fix it from my side?

import mph
client = mph.start(cores=1)
model = client.load("my_path")
sols = model.solutions()
dats = model.datasets()
print(sols)
print(dats)
for dat in dats:
    print(dat)
    s = model.outer(dat)
    print(s)

OUTPUT:

Traceback (most recent call last):
  File "C:/Users/n/Desktop/d/comsoltest.py", line 10, in <module>
    s = model.outer(dat)
  File "C:\Users\n\AppData\Local\Programs\Python\Python38\lib\site-packages\mph\model.py", line 407, in outer
    if not dataset.exists():
  File "C:\Users\n\AppData\Local\Programs\Python\Python38\lib\site-packages\mph\node.py", line 278, in exists
    return (self.java is not None)
  File "C:\Users\n\AppData\Local\Programs\Python\Python38\lib\site-packages\mph\node.py", line 212, in java
    return eval(self.groups.get(name))
TypeError: eval() arg 1 must be a string, bytes or code object
['Solution 1', 'Parametric Solutions 1', 'wl=1.15E-6']
['Study 1//Solution 1', 'Study 1//Parametric Solutions 1']
Study 1//Solution 1

Process finished with exit code 1
byquip commented 2 years ago

removing slash "//" solved this problem.

john-hen commented 2 years ago

You know, this may actually be a bug. But I've only briefly looked at your traceback and you've already closed the issue. I may give this a second look some other time.

wakass commented 2 years ago

Having the same issue, removing the slash from the dataset name inside COMSOL is a workaround. Would be great if this could be fixed. Slashes seem to be standard when parametrizing a study.

Windows 10, COMSOL 5.6 btw.

john-hen commented 2 years ago

Fixed in version 1.1.2, released today.