[yt-users] Error in TotalMass in RAMSES
Sam Geen
samgeen at astro.ox.ac.uk
Mon Feb 3 07:51:05 PST 2014
OK, thanks! Using CellMassMsun seems to work. For the frontend, I'll try
to submit a PR when I get time.
On 03/02/14 16:28, Matthew Turk wrote:
> Hi Sam,
>
> On Mon, Feb 3, 2014 at 8:34 AM, Sam Geen <samgeen at astro.ox.ac.uk> wrote:
>> Hi,
>>
>> I'm trying to find the total energy (kinetic and thermal) in grid cells in a
>> gas-only simulation in RAMSES. I was playing with the functions in the
>> documentation when I ran into an error "YTCouldNotGenerateField: Could field
>> '('all', 'particle_mass')' in info_00014 could not be generated." (full log
>> below)
>>
>> I'm unsure if this is a problem with the RAMSES frontend throwing an error
>> if there are no particles present, or something else (e.g. whether it's not
>> supposed to work with gas-only simulations). I'm sure there's probably a
>> better way to achieve what I was trying to do, but I thought I'd post this
>> up here in case it's a bug.
> Hmm, it should definitely more gracefully handle that, but I think off
> hand it looks like it's just forcing particle discovery. I'd say you
> should be able to do:
>
> dd.quantities["TotalQuantity"]("CellMassMsun")
>
> to get the total mass in the simulation instead.
>
>> Incidentally - would it be a problem if the RAMSES accepted "output_XXXXX"
>> rather than just "output_XXXXX/info_XXXXX.txt"? The latter is more
>> cumbersome, but I suppose the former might cause problems if another code
>> also uses the format "output_XXXXX".
> I suspect this wouldn't be a problem at all -- the changes would have
> to happen two places:
>
> * is_valid in RAMSESStaticOutput should check if isdir and if
> os.path.exists(os.path.join(fn, "info_whatever.txt")) where it
> computes the whatever from the path
> * __init__ in same should guess similarly and update the argument
>
> -Matt
>
>> Cheers,
>>
>> Sam
>>
>> ---
>> (c.f.
>> http://yt-project.org/docs/dev/analyzing/objects.html#processing-objects-derived-quantities)
>> In [18]: dd.quantities["TotalMass"]()
>> yt : [DEBUG ] 2014-02-03 12:42:12,067 Filling Density with 174760
>> (2.287e-02 9.034e+01) (174760 zones)
>> ---------------------------------------------------------------------------
>> YTCouldNotGenerateField Traceback (most recent call last)
>> <ipython-input-18-7ea9fe75efad> in <module>()
>> ----> 1 dd.quantities["TotalMass"]()
>>
>> /home/samgeen/Programming/yt/yt/yt/data_objects/derived_quantities.pyc in
>> __call__(self, *args, **kwargs)
>> 63 chunks = self._data_source.chunks([], chunking_style="io")
>> 64 for ds in parallel_objects(chunks, -1):
>> ---> 65 rv = self.func(ds, *args, **kwargs)
>> 66 if not iterable(rv): rv = (rv,)
>> 67 for i in range(self.n_ret): retvals[i].append(rv[i])
>>
>> /home/samgeen/Programming/yt/yt/yt/data_objects/derived_quantities.pyc in
>> _TotalMass(data)
>> 119 cell_mass = 0.0
>> 120 try:
>> --> 121 particle_mass = _TotalQuantity(data,["ParticleMassMsun"])
>> 122 except KeyError:
>> 123 particle_mass = 0.0
>>
>> /home/samgeen/Programming/yt/yt/yt/data_objects/derived_quantities.pyc in
>> _TotalQuantity(data, fields)
>> 697 totals = []
>> 698 for field in fields:
>> --> 699 if data[field].size < 1:
>> 700 totals.append(np.zeros(1,dtype=prec_accum[data[field].dtype])[0])
>> 701 continue
>>
>> /home/samgeen/Programming/yt/yt/yt/data_objects/data_containers.pyc in
>> __getitem__(self, key)
>> 189 return self.field_data[f]
>> 190 else:
>> --> 191 self.get_data(f)
>> 192 # Note that this is less succinct so that we can account for
>> the case
>> 193 # when there are, for example, no elements in the object.
>>
>> /home/samgeen/Programming/yt/yt/yt/data_objects/data_containers.pyc in
>> get_data(self, fields)
>> 580 self.field_data.update(read_particles)
>> 581 fields_to_generate += gen_fluids + gen_particles
>> --> 582 self._generate_fields(fields_to_generate)
>> 583
>> 584 def _generate_fields(self, fields_to_generate):
>>
>> /home/samgeen/Programming/yt/yt/yt/data_objects/data_containers.pyc in
>> _generate_fields(self, fields_to_generate)
>> 596 if field in self.field_data: continue
>> 597 try:
>> --> 598 self.field_data[field] =
>> self._generate_field(field)
>> 599 except GenerationInProgress as gip:
>> 600 for f in gip.fields:
>>
>> /home/samgeen/Programming/yt/yt/yt/data_objects/data_containers.pyc in
>> _generate_field(self, field)
>> 221 tr = self._generate_fluid_field(field)
>> 222 if tr is None:
>> --> 223 raise YTCouldNotGenerateField(field, self.pf)
>> 224 return tr
>> 225
>>
>> YTCouldNotGenerateField: Could field '('all', 'particle_mass')' in
>> info_00014 could not be generated.
>>
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
More information about the yt-users
mailing list