materialsinnovation / pymks

Materials Knowledge System in Python
https://pymks.readthedocs.io/
Other
115 stars 77 forks source link

AttributeError: 'Variables' object has no attribute 'create_output_dict' #586

Open wd15 opened 1 year ago

wd15 commented 1 year ago

It looks like Sfepy has changed its API between version 2022.1 and 2022.3. Need to fix.

btthorn1 commented 1 year ago

Can work around in colab to restore functional solve_fe() if you copy the elastic_fe.py class from github into your notebook and change get_displacement(vec,shape) to the following (the attribute create_output_dict() needed to be changed to create_output() to be compatible with the new SfePy API): def get_displacement(vec, shape): """Extract the displacement data Args:

vec: the output from problem.solve()

  #shape: the grid shape
Returns:
  #displacement field
"""
as_dict = (
    lambda x: x.create_output()
    if hasattr(x, "create_output()")
    else x.create_output()
)
return pipe(
    vec,
    as_dict,
    lambda x: x['u'].data,
    lambda x: np.reshape(x, (tuple(x + 1 for x in shape) + x.shape[-1:])),
)