Пример #1
0
    def init_state(self):
        # Input sampling domain & scaling
        self.dens = 1.0e8
        self.temp = 4.0e8
        self.xhe = 1.0

        self.end_time = 1.0

        self.time_scale = 1.0e-6
        self.density_scale = self.dens
        self.temperature_scale = self.temp * 10

        # do an eos call to set the internal energy scale
        eos = Eos()
        eos_state = EosType()

        eos_state.state.t = self.temp
        eos_state.state.rho = self.dens

        # pick a composition for normalization of Ye = 0.5 w/ abar = 12, zbar = 6
        eos_state.state.abar = 12.0
        eos_state.state.zbar = 6.0
        eos_state.state.y_e = eos_state.state.zbar / eos_state.state.abar
        eos_state.state.mu_e = 1.0 / eos_state.state.y_e

        # use_raw_inputs uses only abar, zbar, y_e, mu_e for the EOS call
        # instead of setting those from the mass fractions
        eos.evaluate(eos_state.eos_input_rt, eos_state, use_raw_inputs=True)

        self.energy_scale = eos_state.state.e

        print("density_scale = ", self.density_scale)
        print("temperature_scale = ", self.temperature_scale)
        print("energy_scale = ", self.energy_scale)
Пример #2
0
    def __init__(self):
        self.NetworkModule = SKM.Network()
        self.ActualNetworkModule = SKM.Actual_Network()
        self.RHSModule = SKM.actual_rhs_module
        self.eos = Eos()

        self.nspec = self.ActualNetworkModule.nspec
        self.nspec_evolve = self.ActualNetworkModule.nspec_evolve

        self.aion = self.ActualNetworkModule.aion
        self.aion_inv = self.NetworkModule.aion_inv

        # These are python zero based indexes
        self.net_itemp = self.nspec_evolve
        self.net_ienuc = self.nspec_evolve + 1

        self.short_species_names = [
            self.NetworkModule.get_network_short_species_name(i + 1).decode(
                "ASCII").strip().lower() for i in range(self.nspec)
        ]
        self.species_names = [
            self.NetworkModule.get_network_species_name(i + 1).decode(
                "ASCII").strip().lower() for i in range(self.nspec)
        ]
        self.species_map = dict([
            (name, i) for i, name in enumerate(self.short_species_names)
        ])
        self.long_short_species_map = dict([
            (long_name, short_name) for long_name, short_name in zip(
                self.species_names, self.short_species_names)
        ])
        self.short_long_species_map = dict([
            (short_name, long_name) for long_name, short_name in zip(
                self.species_names, self.short_species_names)
        ])
Пример #3
0
class Network(object):
    def __init__(self):
        self.NetworkModule = SKM.Network()
        self.ActualNetworkModule = SKM.Actual_Network()
        self.RHSModule = SKM.actual_rhs_module
        self.eos = Eos()

        self.nspec = self.ActualNetworkModule.nspec
        self.nspec_evolve = self.ActualNetworkModule.nspec_evolve

        self.aion = self.ActualNetworkModule.aion
        self.aion_inv = self.NetworkModule.aion_inv

        # These are python zero based indexes
        self.net_itemp = self.nspec_evolve
        self.net_ienuc = self.nspec_evolve + 1

        self.short_species_names = [self.NetworkModule.get_network_short_species_name(i+1).decode("ASCII").strip().lower() for i in range(self.nspec)]
        self.species_names = [self.NetworkModule.get_network_species_name(i+1).decode("ASCII").strip().lower() for i in range(self.nspec)]
        self.species_map = dict([(name, i) for i, name in enumerate(self.short_species_names)])
        self.long_short_species_map = dict([(long_name, short_name) for long_name, short_name in zip(self.species_names, self.short_species_names)])
        self.short_long_species_map = dict([(short_name, long_name) for long_name, short_name in zip(self.species_names, self.short_species_names)])

    def shorten_species(self, long_species_name):
        return self.long_short_species_map[long_species_name]

    def lengthen_species(self, short_species_name):
        return self.short_long_species_map[short_species_name]

    def rhs(self, burn_state):
        n_rhs = burn_state.state.n_rhs
        n_jac = burn_state.state.n_jac
        eos_state = burn_state.to_eos_type()
        self.eos.evaluate(eos_state.eos_input_rt, eos_state)
        burn_state.from_eos_type(eos_state)
        self.RHSModule.actual_rhs(burn_state.state)

        # Restore n_rhs, n_jac without incrementing
        # since we want them to be valid for the
        # statistics of a preceding burn.
        burn_state.state.n_rhs = n_rhs
        burn_state.state.n_jac = n_jac


    def jacobian(self, burn_state):
        n_rhs = burn_state.state.n_rhs
        n_jac = burn_state.state.n_jac
        eos_state = burn_state.to_eos_type()
        self.eos.evaluate(eos_state.eos_input_rt, eos_state)
        burn_state.from_eos_type(eos_state)
        self.RHSModule.actual_jac(burn_state.state)

        # Restore n_rhs, n_jac without incrementing
        # since we want them to be valid for the
        # statistics of a preceding burn.
        burn_state.state.n_rhs = n_rhs
        burn_state.state.n_jac = n_jac
Пример #4
0
def starkiller_initialize(probin_filename):
    try:
        Eos._initialize_safe()
    except:
        print("EOS cannot be initialized.")
        raise

    try:
        Network._initialize_safe()
    except:
        print("Network cannot be initialized.")
        raise

    skinit = SKM.Starkiller_Initialization_Module()
    skinit.starkiller_initialize(probin_filename)

    eos = Eos()
    net = Network()

    print("\nInitialized StarKiller with ...")
    print("- EOS:     {}".format(eos.name))
    print("- Network: {}".format(net.name))
Пример #5
0
    def __init__(self):
        self.NetworkModule = SKM.Network()
        self.ActualNetworkModule = SKM.Actual_Network()
        self.RHSModule = SKM.actual_rhs_module
        self.eos = Eos()

        self.nspec = self.ActualNetworkModule.nspec
        self.nspec_evolve = self.ActualNetworkModule.nspec_evolve

        self.aion = self.ActualNetworkModule.aion
        self.aion_inv = self.NetworkModule.aion_inv

        # These are python zero based indexes
        self.net_itemp = self.nspec_evolve
        self.net_ienuc = self.nspec_evolve + 1

        self.short_species_names = [self.NetworkModule.get_network_short_species_name(i+1).decode("ASCII").strip().lower() for i in range(self.nspec)]
        self.species_names = [self.NetworkModule.get_network_species_name(i+1).decode("ASCII").strip().lower() for i in range(self.nspec)]
        self.species_map = dict([(name, i) for i, name in enumerate(self.short_species_names)])
        self.long_short_species_map = dict([(long_name, short_name) for long_name, short_name in zip(self.species_names, self.short_species_names)])
        self.short_long_species_map = dict([(short_name, long_name) for long_name, short_name in zip(self.species_names, self.short_species_names)])
Пример #6
0
class Network(object):
    def __init__(self):
        self.NetworkModule = SKM.Network()
        self.ActualNetworkModule = SKM.Actual_Network()
        self.RHSModule = SKM.actual_rhs_module
        self.eos = Eos()

        self.name = self.NetworkModule.get_network_name().decode(
            "ASCII").strip().lower()

        self.nspec = self.ActualNetworkModule.nspec

        self.aion = self.ActualNetworkModule.aion
        self.aion_inv = self.NetworkModule.aion_inv

        # These are python zero based indexes
        self.net_itemp = self.nspec
        self.net_ienuc = self.nspec + 1

        self.short_species_names = [
            self.NetworkModule.get_network_short_species_name(i + 1).decode(
                "ASCII").strip().lower() for i in range(self.nspec)
        ]
        self.species_names = [
            self.NetworkModule.get_network_species_name(i + 1).decode(
                "ASCII").strip().lower() for i in range(self.nspec)
        ]
        self.species_map = dict([
            (name, i) for i, name in enumerate(self.short_species_names)
        ])
        self.long_short_species_map = dict([
            (long_name, short_name) for long_name, short_name in zip(
                self.species_names, self.short_species_names)
        ])
        self.short_long_species_map = dict([
            (short_name, long_name) for long_name, short_name in zip(
                self.species_names, self.short_species_names)
        ])

    def shorten_species(self, long_species_name):
        return self.long_short_species_map[long_species_name]

    def lengthen_species(self, short_species_name):
        return self.short_long_species_map[short_species_name]

    def rhs(self, burn_state):
        n_rhs = burn_state.state.n_rhs
        n_jac = burn_state.state.n_jac
        eos_state = burn_state.to_eos_type()
        self.eos.evaluate(eos_state.eos_input_rt, eos_state)
        burn_state.from_eos_type(eos_state)
        self.RHSModule.actual_rhs(burn_state.state)

        # Restore n_rhs, n_jac without incrementing
        # since we want them to be valid for the
        # statistics of a preceding burn.
        burn_state.state.n_rhs = n_rhs
        burn_state.state.n_jac = n_jac

    def jacobian(self, burn_state):
        n_rhs = burn_state.state.n_rhs
        n_jac = burn_state.state.n_jac
        eos_state = burn_state.to_eos_type()
        self.eos.evaluate(eos_state.eos_input_rt, eos_state)
        burn_state.from_eos_type(eos_state)
        self.RHSModule.actual_jac(burn_state.state)

        # Restore n_rhs, n_jac without incrementing
        # since we want them to be valid for the
        # statistics of a preceding burn.
        burn_state.state.n_rhs = n_rhs
        burn_state.state.n_jac = n_jac

    @staticmethod
    def _initialize_safe():
        return True
Пример #7
0
eos_state = EosType()

# Note that variables in the eos type are all lowercase.
# Use of the wrong case will cause a silent failure where
# the respective variable is not set.
eos_state.state.rho = args.density
eos_state.state.t = args.temperature

use_raw_inputs = False
if args.mass_fractions:
    eos_state.state.xn = np.array(args.mass_fractions)
    use_raw_inputs = False
else:
    eos_state.state.abar = args.abar
    eos_state.state.zbar = args.zbar
    eos_state.state.y_e = args.zbar/args.abar
    eos_state.state.mu_e = 1.0/eos_state.state.y_e
    use_raw_inputs = True

print("Before EOS call:")
print(eos_state.state)

# use_raw_inputs = True will tell the EOS interface not to
# use the mass fractions to set abar, zbar before calling
# the actual EOS subroutine.
eos = Eos()
eos.evaluate(eos_state.eos_input_rt, eos_state, use_raw_inputs=use_raw_inputs)

print("After EOS call:")
print(eos_state.state)