srbonilla / WoMa

Other
13 stars 7 forks source link

Missing entropies and load issue #3

Closed JingyaoDOU closed 3 years ago

JingyaoDOU commented 3 years ago

Dear WoMa developer, when I generate a woma snapshot and save it to the hdf5 file, it works well and can be read and run by swift. But when I use

import swiftsimio as SW
data=sw.load(snapshot)

to try to read the file I just saved from woma,(the same code I use to read snapshot generated by swift) it gives the error, below is the error:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-462-dddfc3f556c1> in <module>
     11 
     12 # Load
---> 13 data1 = sw.load(snapshot)
     14 # pos1 = data.gas.coordinates.to(unyt.Rearth)-box_mid
     15 # id1 = data.gas.particle_ids

~/miniconda3/envs/env1/lib/python3.8/site-packages/swiftsimio/__init__.py in load(filename, mask)
     93     """
     94 
---> 95     return SWIFTDataset(filename, mask=mask)
     96 
     97 

~/miniconda3/envs/env1/lib/python3.8/site-packages/swiftsimio/reader.py in __init__(self, filename, mask)
   1451             self.mask.convert_masks_to_ranges()
   1452 
-> 1453         self.get_units()
   1454         self.get_metadata()
   1455         self.create_particle_datasets()

~/miniconda3/envs/env1/lib/python3.8/site-packages/swiftsimio/reader.py in get_units(self)
   1476         """
   1477 
-> 1478         self.units = SWIFTUnits(self.filename)
   1479 
   1480         return

~/miniconda3/envs/env1/lib/python3.8/site-packages/swiftsimio/reader.py in __init__(self, filename)
    164         self.filename = filename
    165 
--> 166         self.get_unit_dictionary()
    167 
    168         return

~/miniconda3/envs/env1/lib/python3.8/site-packages/swiftsimio/reader.py in get_unit_dictionary(self)
    177         """
    178         with h5py.File(self.filename, "r") as handle:
--> 179             self.units = {
    180                 name: unyt.unyt_quantity(
    181                     value[0], units=metadata.unit_types.unit_names_to_unyt[name]

~/miniconda3/envs/env1/lib/python3.8/site-packages/swiftsimio/reader.py in <dictcomp>(.0)
    179             self.units = {
    180                 name: unyt.unyt_quantity(
--> 181                     value[0], units=metadata.unit_types.unit_names_to_unyt[name]
    182                 )
    183                 for name, value in handle["Units"].attrs.items()

IndexError: invalid index to scalar variable.

When saving the particles data to the hdf5 file, I also include the entropies in the file, but the snapshot I got back from swift shows all the entropies are zero. Is there any configure option I could use to take track of the entropies during the planetary simulations.

In terms of the initial planetesimals generated by WoMa or Seagen, is there any feature included in the swift that I could use to cool the planetesimals( velocity dumping and entropy forcing )? I found the '--enable-planetary-fixed-entropy' option which I assume is used for entropy forcing. What about the velocity dumping, do I need to alter the source code in order to do that?

Seems like too many questions, really appreciate it if you could reply.

Cheers

srbonilla commented 3 years ago

Hi,

Thanks for the post. I'll do my best to answer all your questions:

As far as I know swiftsimio is not designed to read initial conditions (ICs) files, just swift output snapshots, it turns out those two are different from each other. So nothing I can do about it.

Entropies are not being computed on each timestep of the simulation by default. If you want to compute them and save them on each snapshot you will have to modify the source code. Another option is using:

import woma
woma.load_eos_tables()
A1_s = woma.eos.eos.A1_s_u_rho(A1_u, A1_rho, A1_mat_id)

note you only need to load the EoS tables once per script. A1_u, A1_rho, and A1_mat_id can be obtain from the snapshot using swiftsimio. Make sure they're just numpy arrays in SI units.

Indeed --enable-planetary-fixed-entropy fixes the entropy of every particle. Make sure when you create your ICs to have entropies in it. You will need to set do_entropies=True when saving your particle configuration in woma. And no, there is nothing to dump velocities in swift, indeed you will need to alter the source code for that. Although I would not recommend that approach, after settling the particles with dumped velocities, if you turn off the velocity dumping particles will start moving again as if nothing has happen. We found the best approach to settle a planet is just fixing the entropy.

I hope that was helpful. If you have any more questions please let me know.

Best, Sergio

JingyaoDOU commented 3 years ago

Hi Sergio, That's pretty helpful, thank you very much!

Best regards, Jingyao