ascot4fusion / ascot5

ASCOT5 is a high-performance orbit-following code for fusion plasma physics and engineering
https://ascot4fusion.github.io/ascot5/
GNU Lesser General Public License v3.0
31 stars 9 forks source link

AttributeError: 'Unit' object has no attribute 'value' #35

Closed saicma closed 1 month ago

saicma commented 12 months ago

Hi ASCOT Team,

I am currently testing ASCOT5 on Ubuntu 22.04.1 LTS within a virtual machine. During my initial test, while running the Live Simulations part of the introduction under the ascotenv environment, I encountered an AttributeError.


AttributeError Traceback (most recent call last) Cell In[18], line 10 8 # Marker input can be anything, but here we just use the one from ascot.h5 9 mrk = a5.data.marker.active.read() ---> 10 a5.simulation_initmarkers(**mrk) 12 # Options input can also be anything, but here we just use the one from ascot.h5 13 opt = a5.data.options.active.read()

File ~/ascot5/ascot5/a5py/ascotpy/libsimulate.py:231, in LibSimulate.simulation_initmarkers(self, *mrk) 229 p.pitch = mrk["pitch"][i] 230 p.zeta = mrk["zeta"][i] --> 231 p.mass = mrk["mass"][i] unyt.atomic_mass_unit.value 232 p.charge = mrk["charge"][i] * unyt.elementary_charge.value 233 p.anum = mrk["anum"][i]

AttributeError: 'Unit' object has no attribute 'value'

Why did this happen? Does the unyt package have a wrongly defined method for unyt.atomic_mass_unit.value? I hope you can shed light on the reason.

Thanks, Saic

miekkasarki commented 12 months ago

Hi Saic!

This is most likely due to the recent updates in the unyt package. I was getting similar errors as well, so I made this commit:

https://github.com/ascot4fusion/ascot5/commit/7eb016497c553ea9ad752e0df25cb07294ad78e6

i.e. the supported unyt version is 2.9.5. Could you check if you get the error using that version of unyt?

miekkasarki commented 1 month ago

As of 5.5.5 this is now effectively fixed as unyt 3.0 is supported