[yt-users] error in the field SoundSpeed?

Luigi Iapichino luigi at ita.uni-heidelberg.de
Tue May 24 02:36:44 PDT 2011


Hi Matt,

thanks for the suggestions. I added to my file ~/.yt/my_plugins.py the 
following lines:

def _ThermalEnergy(field, data):
    if data.pf["HydroMethod"] == 2:
        return data["Total_Energy"]
    else:
        if data.pf["DualEnergyFormalism"]:
            return data["GasEnergy"]
        else:
            return data["Total_Energy"] - 0.5*(
                   data["x-velocity"]**2.0
                 + data["y-velocity"]**2.0
                 + data["z-velocity"]**2.0 )
add_field("ThermalEnergy", function=_ThermalEnergy,
          units=r"\rm{ergs}/\rm{cm^3}")

def _convertEnergy(data):
    return data.convert("x-velocity")**2.0
 
def _GasEnergy(field, data):
     return data["Gas_Energy"] / _convertEnergy(data)
add_field("GasEnergy", function=_GasEnergy,
           units=r"\rm{ergs}/\rm{g}", convert_function=_convertEnergy)


def _TotalEnergy(field, data):
    return data["Total_Energy"] / _convertEnergy(data)
add_field("TotalEnergy", function=_TotalEnergy,
          display_name = "\mathrm{Total}\/\mathrm{Energy}",
          units=r"\rm{ergs}/\rm{g}", convert_function=_convertEnergy)

and I switched back to the unstable branch. Still, I have a problem (that I 
noticed also other times): what I put in my_plugins.py is added to yt, but it 
does not override the existing definitions. In my case, I get again an error, 
because yt takes the definition of ThermalEnergy from 
yt-unstable/src/yt-hg/yt/frontends/enzo/fields.py , rather than from 
my_plugins.py (I can even copy the definitions in my yt script, but it 
doesn't change the problem). Is there a way to arrange my script in such a 
way to give priority to the definitions in my_plugins.py?

Cheers,

  Luigi

On Monday 23 May 2011, Matthew Turk wrote:
> Hi Luigi,
>
> Yes -- in the past we mutually aliased the fields "GasEnergy" and
> "Gas_Energy" to each other, so that if one was not found the other was
> looked for.  Unfortunately, this aliasing caused infinite recursion
> loops:
>
> https://bitbucket.org/yt_analysis/yt/changeset/258083307f14
>
> so we had to remove this dual-aliasing.  I had hoped it wouldn't cause
> problems; I tried very hard with Sam to come up with a way around
> this, so that we could leave the aliasing in.  Unfortunately without
> reworking the field container, we could not.  I am hoping that by the
> end of the calendar year we will be able to rework the field container
> to be more flexible.  However, for now, it should suffice to add into
> your plugins file the lines that were removed in the linked commit.
> This also took place while we standardized in Enzo on GasEnergy rather
> than Gas_Energy (although I personally preferred the hyphen :):
>
> https://groups.google.com/d/topic/enzo-dev/64j9OZEAzcU/discussion
>
> Sorry for the inconvenience -- let me know if the plugins fix doesn't
> work and we'll figure something else out.
>
> -Matt
>
> On Mon, May 23, 2011 at 3:49 PM,  <luigi at ita.uni-heidelberg.de> wrote:
> > Dear all,
> >
> > I want to point out that, in the unstable branch, any attempt of using
> > the field SoundSpeed returns an error. I have the impression that yt
> > looks for GasEnergy, but in my dataset I have Gas_Energy defined. In the
> > stable branch everything works well. I hope it does not depend on the
> > data I'm analysing (some old Enzo 1.0 output)...
> > Cheers,
> >
> >  Luigi



-- 

---------------------------------------------------------------

Luigi Iapichino
Zentrum fuer Astronomie der Universitaet Heidelberg
Institut fuer Theoretische Astrophysik
Albert-Ueberle-Str. 2, D-69120 Heidelberg, Germany
Tel: +49 6221 548983, Fax: +49 6221 544221
e-mail: luigi at ita.uni-heidelberg.de
URL: http://www.ita.uni-heidelberg.de/~luigi/



More information about the yt-users mailing list