def __init__(self): PhysicalConstants.__init__( self, 1.0, # Unit length (m) 1.0, # Unit mass (kg) 1.0, # Unit time (sec) 1.0, # Unit temp (kelvin) 1.0) # Unit charge (coulomb) return
def __init__(self): PhysicalConstants.__init__( self, 149597870700.0, # Unit length (m) 1.98892e30, # Unit mass (kg) 365.25 * 3600 * 24, # Unit time (sec) 1.0, # Unit temp (kelvin) 1.0) # Unit charge (coulomb) return
def __init__(self): PhysicalConstants.__init__( self, 3.08567757e22, # Unit length (m) 1.9891e36, # Unit mass (kg) 3.155674e19, # Unit time (sec) 1.0, # Unit temp (kelvin) 1.0) # Unit charge (coulomb) return
def _ConstantStrengthFactory(*args, **kwargs): # The calling routine must provide the appropriate C++ constructor. CSConstructor = kwargs["CSConstructor"] # The arguments that need to be passed to this method. expectedArgs = ["materialName", "units"] optionalKwArgs = {"mu0": None, "Y0": None} # The base units for parameters in this file. cgs = PhysicalConstants( 0.01, # Length in m 0.001, # Mass in kg 1.0) # Time in sec # What sort of information did the user pass in? if ("materialName" in kwargs or len(args) > 0 and type(args[0]) is str): # It looks like the user is trying to use one of the libarary canned values. # Evaluate the arguments to the method. if len(args) > 0: if len(args) != len(expectedArgs): raise ValueError, expectedUsageString for i in xrange(len(expectedArgs)): exec("%s = args[i]" % expectedArgs[i]) for arg in optionalKwArgs: exec("%s = optionalKwArgs['%s']" % (arg, arg)) else: for arg in kwargs: if arg not in (expectedArgs + optionalKwArgs.keys() + ["CSConstructor"]): raise ValueError, expectedUsageString exec("%s = kwargs['%s']" % (arg, arg)) for arg in optionalKwArgs: if arg not in kwargs: exec("%s = optionalKwArgs['%s']" % (arg, arg)) # Check that the caller specified a valid material label. mat = materialName.lower() if mat not in SpheralMaterialPropertiesLib: raise ValueError, "You must specify one of %s" % str( SpheralMaterialPropertiesLib.keys()) if ("mu0" not in SpheralMaterialPropertiesLib[mat] or "Y0" not in SpheralMaterialPropertiesLib[mat]): raise ValueError, "The material %s does not provide strength paramters." % materialName # Extract the parameters for this material. if mu0 is None: mu0 = SpheralMaterialPropertiesLib[mat]["mu0"] if Y0 is None: Y0 = SpheralMaterialPropertiesLib[mat]["Y0"] # Figure out the conversions to the requested units. lconv = cgs.unitLengthMeters / units.unitLengthMeters mconv = cgs.unitMassKg / units.unitMassKg tconv = cgs.unitTimeSec / units.unitTimeSec rhoConv = mconv / (lconv * lconv * lconv) Pconv = mconv / (lconv * tconv * tconv) specificEconv = (lconv / tconv)**2 # Build the arguments for constructing the ConstantStrength. passargs = [mu0 * Pconv, Y0 * Pconv] passkwargs = {} else: # Just pass through the arguments. passargs = args passkwargs = kwargs del passkwargs["CSConstructor"] # Return the EOS. return CSConstructor(*tuple(passargs), **passkwargs)
def _TillotsonFactory(*args, **kwargs): # The calling routine must provide the appropriate C++ constructor. TillConstructor = kwargs["TillConstructor"] # The arguments that need to be passed to this method. expectedArgs = ["materialName", "etamin", "etamax", "units"] optionalKwArgs = { "etamin_solid": 0.0, "etamax_solid": 1e200, "externalPressure": 0.0, "minimumPressure": -1e200, "maximumPressure": 1e200, "minimumPressureDamage": 0.0, "minPressureType": PressureFloor } # The base units for parameters in this file. CGS = PhysicalConstants( 0.01, # Length in m 0.001, # Mass in kg 1.0) # Time in sec # What sort of information did the user pass in? if ("materialName" in kwargs or len(args) > 0 and type(args[0]) is str): # It looks like the user is trying to use one of the libarary canned values. # Evaluate the arguments to the method. if (len(args) > len(expectedArgs) or (len(args) + len(kwargs) < len(expectedArgs))): # insist on formal mandatory arguments raise ValueError, expectedUsageString for i in xrange(len(args)): # deal with mandatory args exec("%s = args[i]" % expectedArgs[i]) for arg in kwargs: # deal with optional args if arg not in (expectedArgs + optionalKwArgs.keys() + ["TillConstructor"]): raise ValueError, expectedUsageString exec("%s = kwargs['%s']" % (arg, arg)) for arg in optionalKwArgs: # make sure all optional args have a value if arg not in kwargs: exec("%s = optionalKwArgs['%s']" % (arg, arg)) import sys # Check that the caller specified a valid material label. mat = materialName.lower() if mat not in SpheralMaterialPropertiesLib: raise ValueError, "You must specify one of %s" % str( SpheralMaterialPropertiesLib.keys()) if "Tillotson" not in SpheralMaterialPropertiesLib[mat]: raise ValueError, "The material %s does not provide Tillotson paramters." % materialName # Extract the parameters for this material. params = dict(SpheralMaterialPropertiesLib[mat]["Tillotson"]) # Figure out the conversions to the requested units. lconv = CGS.unitLengthMeters / units.unitLengthMeters mconv = CGS.unitMassKg / units.unitMassKg tconv = CGS.unitTimeSec / units.unitTimeSec rhoConv = mconv / (lconv * lconv * lconv) Pconv = mconv / (lconv * tconv * tconv) specificEconv = (lconv / tconv)**2 # Build the arguments for constructing the Tillotson. passargs = [ SpheralMaterialPropertiesLib[mat]["rho0"] * rhoConv, etamin, etamax, etamin_solid, etamax_solid, params["a"], params["b"], params["A"] * Pconv, params["B"] * Pconv, params["alpha"], params["beta"], params["eps0"] * specificEconv, params["epsLiquid"] * specificEconv, params["epsVapor"] * specificEconv, SpheralMaterialPropertiesLib[mat]["atomicWeight"] * mconv, units ] passargs.extend([ externalPressure, minimumPressure, maximumPressure, minimumPressureDamage, minPressureType ]) passkwargs = {} else: # Just pass through the arguments. passargs = args passkwargs = kwargs del passkwargs["TillConstructor"] # Return the EOS. return TillConstructor(*tuple(passargs), **passkwargs)
def __init__(self): PhysicalConstants.__init__(self, 0.01, # Unit length (m) 0.001, # Unit mass (kg) 1.0e-6) # Unit time (sec) return