[FLASH-USERS] Changing the system of units

Sean Lynch sean.m.lynch at drexel.edu
Wed Aug 10 10:27:32 EDT 2011


I found the problem with PhysicalConstants_get. It turns out that I had a typo in the word Length (Lenth).

I changed:
call PhysicalConstants_get("ideal gas constant", eos_gasConstant, &
      unitLenth="pc", unitTime="yr", unitMass="Msun")

to:
call PhysicalConstants_get("ideal gas constant", eos_gasConstant, &
      unitLength="pc", unitTime="yr", unitMass="Msun")

Also I noticed that the documentation (for Flash 3.3) lists the optional arguments as they way they used to be in an earlier version. Instead of unitLength, it has len_unit, etc.
This could also be a source of errors.

-Sean

On Aug 8, 2011, at 3:23 PM, Aaron Froese wrote:

> Hi Sean,
> 
> I have encountered the same error with PhysicalConstants_get, but have not endeavoured to fix it.  Rather than rewriting each call to PhysicalConstants_get, I think it would be more efficient to add a new unit system to pc_checkCGSMKS in pc_utilities.F90 and then add new if statements to PhysicalConstants_get.F90
> 
> if (present(unitLength)) then
>          call pc_findUnit (unitLength, pc_baseUnitLength, indexUnit)
>          if (indexUnit == 0) return
>          scaleLength = pc_arrayUnit(indexUnit)%cgsValue
> else
>          scaleLength = 1.e0
>          if (pc_SISystem == 2) scaleLength = 1.E2  ! meters
>          if (pc_SISystem == 3) scaleLength = 3.08568e18  ! parsecs
> endif
> 
> Of course, both of our methods still require the solver units to be correctly adjusted as well.
> 
> Aaron
> ________________________________________
> From: Sean Lynch [sean.m.lynch at drexel.edu]
> Sent: Sunday, August 07, 2011 10:42 AM
> To: Aaron Froese
> Cc: flash-users
> Subject: Re: [FLASH-USERS] Changing the system of units
> 
> Aaron,
> 
> I did realize that this would require additional coding, however this doesn't seem like such an issue.
> 
> As far as I know any routine that needs some constant will have to call PhysicalConstants_get. So in order to make sure everything is in the right units I need to two things: 1) Set up my simulation in the correct units, and 2) find all the places where the modules that the simulation is using call PhysicalConstants_get. Then all I need to do is override this with my own version of the routine that is essentially the same but calls PhysicalConstants_get with units specified.
> 
> For example, one unit that would need to be modified for my simulation is Eos_init.F90 because the Eos unit needs the ideal gas constant. The original subroutine Eos_init(myPE) contains the line:
> 
>  call PhysicalConstants_get("ideal gas constant", eos_gasConstant)
> 
> So I copy the file Eos_init.F90 to my Simulation directory and change this call to
> 
>  call PhysicalConstants_get("ideal gas constant", eos_gasConstant, &
>       unitLenth="pc", unitTime="yr", unitMass="Msun")
> 
> However, at compile time I get the error
> 
> In file Eos_init.F90:25
>        unitLenth="pc", unitTime="yr", unitMass="Msun")                                                     1
> 
> Error: There is no specific subroutine for the generic 'physicalconstants_get' at (1)
> 
> Shouldn't this work? Why am I getting this error?
> 
> Thanks,
> Sean
> 
> On Aug 5, 2011, at 6:33 PM, Aaron Froese wrote:
> 
>> Hi Sean,
>> 
>> The two runtime parameters that determine what unit system the solver works in are
>> 
>> UnitSystem = "CGS" or "SI"
>> pc_unitsbase = "CGS" or "MKS"
>> 
>> In most of the initialization routines, these parameters are read and then used to calculate constant factors.  In Hydro_init.F90, for example:
>> 
>> call RuntimeParameters_get("UnitSystem",          hy_units)
>> 
>> if ( hy_units == "SI" .or. hy_units == "si" ) then
>>   hy_bref = hy_vref*sqrt(4.0*PI*hy_dref*1.e-7)
>> else if ( hy_units == "CGS" .or. hy_units == "cgs" ) then
>>   hy_bref = hy_vref*sqrt(4.0*PI*hy_dref)
>> else
>>   hy_bref = hy_vref*sqrt(hy_dref)
>> end if
>> 
>> As you can see, only CGS and SI are provided in the distribution copy, so changing the solver to use parsecs, solar masses, and mega years would require additional coding.  I think it would be simpler to convert the simulation results from CGS or SI in post-processing.
>> 
>> Cheers,
>> Aaron
>> 
>> 
>> ________________________________________
>> From: flash-users-bounces at flash.uchicago.edu [flash-users-bounces at flash.uchicago.edu] On Behalf Of flash-users-request at flash.uchicago.edu [flash-users-request at flash.uchicago.edu]
>> Sent: Monday, August 01, 2011 10:00 AM
>> To: flash-users at flash.uchicago.edu
>> Subject: flash-users Digest, Vol 46, Issue 1
>> 
>> Send flash-users mailing list submissions to
>>       flash-users at flash.uchicago.edu
>> 
>> To subscribe or unsubscribe via the World Wide Web, visit
>>       http://flash.uchicago.edu/mailman/listinfo/flash-users
>> or, via email, send a message with subject or body 'help' to
>>       flash-users-request at flash.uchicago.edu
>> 
>> You can reach the person managing the list at
>>       flash-users-owner at flash.uchicago.edu
>> 
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of flash-users digest..."
>> 
>> 
>> Today's Topics:
>> 
>>  1.  Changing the system of units (Sean Lynch)
>> 
>> 
>> ----------------------------------------------------------------------
>> 
>> Message: 1
>> Date: Mon, 1 Aug 2011 12:53:34 -0400
>> From: Sean Lynch <sean.m.lynch at drexel.edu>
>> Subject: [FLASH-USERS] Changing the system of units
>> To: flash-users <flash-users at flash.uchicago.edu>
>> Message-ID: <11522DB1-D682-4A7C-A9D8-7AB6B7D92791 at drexel.edu>
>> Content-Type: text/plain; charset=us-ascii
>> 
>> Hello,
>> 
>> I'm trying to set up a simulation that uses parsec, solar mass, and mega year as the base units. I know that I can use PhysicalConstants_get to convert a constant to the correct units. But how would I go about getting the solvers to use the correct units. For instance, how would I make sure that the eos unit is using the correct value of the gas constant, or that the gravity solver is using the correct value of G.
>> 
>> Thanks for your help.
>> 
>> -Sean
>> 
>> ------------------------------
>> 
>> _______________________________________________
>> flash-users mailing list
>> flash-users at flash.uchicago.edu
>> http://flash.uchicago.edu/mailman/listinfo/flash-users
>> 
>> 
>> End of flash-users Digest, Vol 46, Issue 1
>> ******************************************
> 




More information about the flash-users mailing list