wnnet package

A package of python routines to handle webnucleo networks.

wnnet.consts module

This module contains constants for use in the wnnet package. The module also includes all constants from gslconsts. The gsl constants are imported into their corresponding gslconsts namespaces; thus, for example, the speed of light in vacuum in MKSA units would be wnnet.consts.consts.GSL_CONST_MKSA_SPEED_OF_LIGHT while the Euler-Mascheroni constant would be wnnet.consts.math.M_EULER.

wnnet.consts.MeV_to_ergs = 1.602176487e-06

Conversion factor from MeVs to ergs

wnnet.consts.N_A = 6.02214199e+23

Avogadro’s number

wnnet.consts.c = 29979245800.0

Speed of light in vacuum (cm/s)

wnnet.consts.ergs_to_MeV = 624150.9647120418

Conversion factor from ergs to MeVs

wnnet.consts.hbar = 1.05457162825e-27

Planck’s constant divided by 2pi (ergs/s)

wnnet.consts.k_B = 1.3806504e-16

Boltzmann’s constant (ergs/K)

wnnet.consts.m_e = 9.10938188e-28

Electron mass (g)

wnnet.consts.m_e_in_MeV = np.float64(0.5109988947017501)

Electron rest mass (MeV)

wnnet.consts.m_u_in_MeV = np.float64(931.4940282330006)

Amu rest mass (MeV)

wnnet.consts.u = 1.660538782e-24

Amu mass (g)

wnnet.flows module

This module computes various reaction flows in a network.

wnnet.flows.compute_flows(net, t_9, rho, mass_fractions, **kwargs)[source]

A routine to compute flows for a given set of mass fractions at the input temperature and density.

Args:

net: A wnnet network.

t_9 (float): The temperature in 109 K at which to compute the flows.

rho (float): The density in g/cc at which to compute the flows.

mass_fractions (float): A wnutils dictionary of mass fractions.

**kwargs: Allowed optional keyword arguments:

  • nuc_xpath (str): XPath expression to select nuclides for flow computations. Defaults to all species.

  • reac_xpath (str): XPath expression to select reactions for flow computations. Defaults to all reactions.

  • user_funcs (dict): A dictionary of user-defined functions associated with a user_rate key. The prototype for each user rate function should be (reaction, t_9), where t_9 is the temperature in billions of Kelvin and reaction is a wnutils reaction instance. Other data can be bound to the function.

Returns:

A dict of reactions with each item in the dictionary a tuple giving the forward and reverse flow.

wnnet.flows.compute_flows_for_zones(net, zones, nuc_xpath='', reac_xpath='', user_funcs='')[source]

A routine to compute flows for a set of zones.

Args:

net: A wnnet network.

zones (dict): A dictionary of wnutils zone data.

nuc_xpath (str, optional): XPath expression to select nuclides for flow computations. Defaults to all species.

reac_xpath (str, optional): XPath expression to select reactions for flow computations. Defaults to all reactions.

user_funcs (dict, optional): A dictionary of user-defined functions associated with a user_rate key. The prototype for each user rate function should be (reaction, t_9, zone), where t_9 is the temperature in billions of Kelvin and reaction and zone are wnutils reaction and zone instances. Other data can be bound to the function.

Returns:

A dict of flows for each zone. The data for each zone are themselves a dict of reactions with each item in the dictionary a tuple giving the forward and reverse flow.

A routine to compute link flows for a given set of mass fractions at the input temperature and density.

Args:

net: A wnnet network.

t_9 (float): The temperature in 109 K at which to compute the flows.

rho (float): The density in g/cc at which to compute the flows.

mass_fractions (float): A wnutils dictionary of mass fractions.

**kwargs: Allowed optional keyword arguments:

  • nuc_xpath (str): XPath expression to select nuclides for flow computations. Defaults to all species.

  • reac_xpath (str): XPath expression to select reactions for flow computations. Defaults to all reactions.

  • user_funcs (dict): A dictionary of user-defined functions associated with a user_rate key. The prototype for each user rate function should be (reaction, t_9), where t_9 is the temperature in billions of Kelvin and reaction is a wnutils reaction instance. Other data can be bound to the function.

  • direction (str): A string indicating the direction of the links (“forward”, from reactants to reactants and products; “reverse”, from products to reactants and products; “both”, both “forward” and “reverse”). Default is “both”.

  • order (str): A string indicating the order of the links. Default is normal, in which the source and target of the link are in the time-forward direction of the reaction. For reversed, the source and target are in the opposite of the time-forward direction of the reaction such that] the target is the contribution to the source over some interval.

Returns:

A dict of reactions with each item in the dictionary an array of three-element tuple objects. The tuple elements are the source, target, and link flow. The source and target are determined from the time-forward direction of the reaction or the reverse, as indicated by the order argument.

A routine to compute link flows for a set of zones.

Args:

net: A wnnet network.

zones (dict): A dictionary of wnutils zone data.

**kwargs: Allowed optional keyword arguments:

  • nuc_xpath (str): XPath expression to select nuclides for flow computations. Defaults to all species.

  • reac_xpath (str): XPath expression to select reactions for flow computations. Defaults to all reactions.

  • user_funcs (dict): A dictionary of user-defined functions associated with a user_rate key. The prototype for each user rate function should be (reaction, t_9, zone), where t_9 is the temperature in billions of Kelvin and reaction and zone are wnutils reaction and zone instances. Other data can be bound to the function.

  • direction (str): A string indicating the direction of the links (“forward”, from reactants to reactants and products; “reverse”, from products to reactants and products; “both”, both “forward” and “reverse”). Default is “both”.

  • order (str): A string indicating the order of the links. Default is normal, in which the source and target of the link are in the time-forward direction of the reaction. For reversed, the source and target are in the opposite of the time-forward direction of the reaction such that] the target is the contribution to the source over some interval.

  • include_dt (bool): Boolean determining whether to include the dt (time interval) in the flow (True) or not (False). Default is False.

Returns:

A dict of flow links for each zone. The data for each zone are themselves a dict of reactions with each item in the dictionary an array of three-element tuple objects. The source and target are determined from the time-forward direction of the reaction or the reverse, as indicated by the order argument.

wnnet.graph module

A module to create graphs from network data.

The routines in this module allow for a number of optional keyword arguments. Not all keyword arguments are available for each routine, however. The documentation indicates which keyword arguments are appropriate for a given routine.

The possible keyword arguments are:

induced_nuc_xpath (str): An XPath expression to select the subset of nuclides in the graph. The default is all species in the network.

induced_reac_xpath (str): An XPath expression to select the subset of reactions in the graph. The default is all reactions in the network.

flow_type (str) A string giving the flow type to be presented. The possible values are net, which shows the forward minus the reverse flow (or the opposite if the reverse flow is larger), and full, which shows both the foward and reverse flows. The default is net.

direction (str) A string indicting the reaction directions to show. Allowed values are forward, reverse, and both (the default, which shows both forward and reverse).

reaction_color_tuples (list): A list of tuple objects to select arc colors. There is a tuple for each reaction type. The first member of the tuple is an XPath expression to select the reaction type while the second member is a string giving the color for that reaction type. The default is that all arcs are black.

user_funcs (dict): A dictionary of user-defined functions associated with a user_rate key. The prototype for each user rate function should be (reaction, t_9), where t_9 is the temperature in billions of Kelvin and reaction is a wnutils reaction instance. Other data can be bound to the function.

zone_user_funcs (dict): A dictionary of user-defined functions associated with a user_rate key. The prototype for each user rate function should be (reaction, t_9, zone), where t_9 is the temperature in billions of Kelvin and reaction and zone are wnutils reaction and zone instances. Other data can be bound to the function.

threshold (float): The minimum flow (relative to the maximum flow) to be shown on the graph. The default is 0.01.

scale (float): Scaling factor for the maximum weight arc. The default is 10.

state_scaling (float): Scaling factor for isomeric states. The default is 0.35.

allow_isolated_species (bool): Boolean to choose whether to allow isolated species (ones without incoming or outgoing arcs) in the graph. The default is False.

title_func: A function that applies the title to the graph. The function must take one float argument giving the maximum flow. Other data can be bound to the function. The function must return a str giving the title. The default is wnnet.graph.make_t9_rho_flow_string().

zone_title_func: A function that applies the title to the graph. The function must take three arguments. The first is a float giving the maximum flow. The second is the zone object corresponding to the graph while the third is the zone label. Other data can be bound to the function. The function must return a str giving the title. The default is wnnet.graph.make_time_t9_rho_flow_string() for flow graphs and wnnet.graph.make_time_t9_rho_current_string() for integrated current graphs.

node_label_func: A function that applies a label to each node in the graph. The function must take as argument a species name. Other data can be bound to the function. The function must return a str giving the label. The default is wnnet.graph.make_node_label(). The g_names argument for the default is bound by the calling routine.

zone_node_label_func: A function that applies a label to each node in the graph. The function must take as arguments a species name, a zone, and the zone label. Other data can be bound to the function. The function must return a str giving the label. The default is wnnet.graph.make_zone_node_label().

scale_edge_weight_func: A function that applies scales each edge weight in the graph. The function must take four arguments: a dictionary of edge data, the maximum edge weight in the scope of the graph, a scale factor by which to scale the weight (input as scale to this routine), and a threshold for not including the edge in the graph (input as threshold to this routine). Other data can be bound to the function. The function must modify the weight in the edge data and return a bool indicating whether to include the edge in the graph (True) or not (False). The default is wnnet.graph.scale_edge_weight().

graph_attributes (dict): A dictionary of graphviz attributes for the graph. The default is {“outputorder”: “edgesfirst”}.

edge_attributes (dict): A dictionary of grapvhiz attributes for the edges in the graph. The default is {“arrowsize”: 0.2}.

node_attributes (dict): A dictionary of graphviz attributes for the nodes in the graph. The default is { “shape”: “box”, “fontsize”: 16, “style”: “filled”, “fillcolor”: “white” }.

solar_species (list): A list of species to be considered as the naturally occurring species. The default is the list returned from wnnet.graph.get_solar_species().

solar_node_attributes (dict): A dictionary of graphviz attributes to be applied to the solar species in the graph. The default is {“fillcolor”: “yellow”, “style”: “filled”}.

special_node_attributes (dict): A dictionary of graphviz attributes to be applied to the special nodes in the graph. The dictionary has as keys the names of the special nodes and as values a dictionary of graphviz properties to be applied to the given special node.

special_edge_attributes (dict): A dictionary of graphviz attributes to be applied to the special edges in the graph. The dictionary has as keys a tuple (u, v, reaction), where u is the source of the directed edge (i.e., arc), v is the target, and reaction is the reaction from which the arc derives. The reaction tuple element serves as a key in the multi-digraph to distinguish parallel arcs. The values of the dictionary are each a dictionary of graphviz properties to be applied to the given special edge.

wnnet.graph.create_flow_graph(net, t_9, rho, mass_fractions, **kwargs)[source]
A routine to create a flow graph for a given set of mass fractions at

the input temperature and density.

Args:

net: A wnnet network.

t_9 (float): The temperature in 109 K at which to compute the flows.

rho (float): The density in g/cc at which to compute the flows.

mass_fractions (float): A wnutils dictionary of mass fractions.

**kwargs: The allowed optional keyword arguments for this routine are: induced_nuc_xpath, induced_reac_xpath, flow_type, user_funcs, reaction_color_tuples, threshold, scale, state_scaling, allow_isolated_species, title_func, node_label_func, scale_edge_weight_func, graph_attributes, edge_attributes, node_attributes, solar_species, solar_node_attributes, special_node_attributes, special_edge_attributes.

Returns:

A networkx multidigraph showing the flows.

wnnet.graph.create_network_graph(net, **kwargs)[source]

A routine to create a network graph showing species and reactions among them.

Args:

net: A wnnet network.

**kwargs: The allowed optional keyword arguments for this routine are: induced_nuc_xpath, induced_reac_xpath, direction, reaction_color_tuples, threshold, scale, state_scaling, allow_isolated_species, node_label_func, graph_attributes, edge_attributes, node_attributes, solar_species, solar_node_attributes, special_node_attributes, special_edge_attributes.

Returns:

A networkx multidigraph showing the network; that is, the nuclides and reactions among them.

wnnet.graph.create_zone_flow_graphs(net, zones, **kwargs)[source]

A routine to create flow graphs for a set of zones.

Args:

net: A wnnet network.

zones: A wnutils dictionary of zones.

**kwargs: The allowed optional keyword arguments for this routine are: induced_nuc_xpath, induced_reac_xpath, flow_type, zone_user_funcs, reaction_color_tuples, threshold, scale, state_scaling, allow_isolated_species, zone_title_func, zone_node_label_func, scale_edge_weight_func, graph_attributes, edge_attributes, node_attributes, solar_species, solar_node_attributes, special_node_attributes, special_edge_attributes.

Returns:

A dict of networkx multidigraphs showing the flows. The keys are the zone labels.

wnnet.graph.create_zone_integrated_current_graphs(net, zones, **kwargs)[source]

A routine to create integrated currents graphs for a set of zones.

Args:

net: A wnnet network.

zones: A wnutils dictionary of zones.

**kwargs: The allowed optional keyword arguments for this routine are: induced_nuc_xpath, induced_reac_xpath, reaction_color_tuples, threshold, scale, state_scaling, allow_isolated_species, zone_title_func, zone_node_label_func, scale_edge_weight_func, graph_attributes, edge_attributes, node_attributes, solar_species, solar_node_attributes, special_node_attributes, special_edge_attributes.

Returns:

A dict of networkx multidigraphs showing the integrated currents. The keys are the zone labels.

wnnet.graph.get_solar_species()[source]

A method to return the naturally-occurring solar-system species.

Returns:

A list. A list containing str of the names of the naturally-occurring solar-system species.

wnnet.graph.make_node_label(name, g_names)[source]

The default node label function.

Args:

name (str): The species name.

g_names (dict): A dictionary of graphviz names. This dictionary is bound to the function by the calling routine.

Returns:

A str. The node label.

wnnet.graph.make_t9_rho_flow_string(f_max, t_9, rho)[source]

The default title function for flow graphs.

Args:

f_max (float): The maximum flow in the scope of the graph.

t_9 (float): The temperature in 109 K at which the flows are computed. This value is bound by the calling function.

rho (float): The density in g/cc at which the flows are computed. This value is bound by the calling function.

Returns:

A str. The title string.

wnnet.graph.make_time_t9_rho_current_string(f_max, zone, zone_label)[source]

The default title function for zone integrated current graphs.

Args:

f_max (float): The maximum integrated current in the scope of the graph.

zone: A wnutils zone object.

zone_label (str or tuple): The label of the zone.

Returns:

A str. The title string.

wnnet.graph.make_time_t9_rho_flow_string(f_max, zone, zone_label)[source]

The default title function for zone flow graphs.

Args:

f_max (float): The maximum flow in the scope of the graph.

zone: A wnutils zone object.

zone_label (str or tuple): The label of the zone.

Returns:

A str. The title string.

wnnet.graph.make_zone_node_label(name, zone, zone_label, g_names)[source]

The default zone node label function.

Args:

name (str): The species name.

zone: A wnutils zone object.

zone_label (str or tuple): The label of the zone.

g_names (dict): A dictionary of graphviz names. This dictionary is bound to the function by the calling routine.

Returns:

A str. The node label.

wnnet.graph.scale_edge_weight(edge_data, f_max, scale, threshold)[source]

The default edge weight scale function.

Args:

edge_data: A dictionary of edge properties.

f_max (float): The maximum edge weight.

scale (float): The factor by which to scale the weight.

threshold (float): The threshold for not including the edge.

Returns:

A bool indicating whether to include the edge (True) or not (False).

wnnet.graph_helper module

Module that holds helper routines for the graph module. This module is not part of the wnnet API. This documentation is shown simply for completeness.

wnnet.graph_helper.add_currents_to_graph(net, zone, d_g, my_args)[source]

Helper function to add current arcs to graph.

wnnet.graph_helper.add_flow_edges(d_g, s_array, t_array, my_weight, key)[source]

Helper function to add flow edges.

wnnet.graph_helper.add_flows_to_graph(net, d_g, my_flows, my_args)[source]

Helper function to add flow arcs to graph.

wnnet.graph_helper.add_reactions_to_graph(net, d_g, my_args)[source]

Helper function to add reaction arcs to graph.

wnnet.graph_helper.apply_edge_attributes(my_graph, edge_attributes)[source]

Helper function to apply attributes to the edges of a graph.

wnnet.graph_helper.apply_graph_attributes(my_graph, graph_attributes)[source]

Helper function to apply attributes to the graph as a whole.

wnnet.graph_helper.apply_node_attributes(my_graph, node_attributes)[source]

Helper function to apply attributes to the nodes of a graph.

wnnet.graph_helper.apply_solar_node_attributes(my_graph, solar_species, solar_node_attributes)[source]

Helper function to apply attributes to the nodes representing solar species in a graph.

wnnet.graph_helper.apply_special_edge_attributes(my_graph, special_edge_attributes)[source]

Helper function to apply attributes to special edges in a graph.

wnnet.graph_helper.apply_special_node_attributes(my_graph, special_node_attributes)[source]

Helper function to apply attributes to special nodes in a graph.

wnnet.graph_helper.color_edges(my_graph, net, color_tuples)[source]

Helper function to color arcs in graph by reaction type.

wnnet.graph_helper.create_flow_graph(net, my_flows, subset_nuclides, anchors, **my_args)[source]

Helper function to create a flow graph.

wnnet.graph_helper.create_integrated_current_graph(net, zone, subset_nuclides, anchors, **my_args)[source]

Helper function to create an integrated current graph.

wnnet.graph_helper.fexp(_x)[source]

Helper function to compute an exponent of a number.

wnnet.graph_helper.fman(_x)[source]

Helper function to compute the mantissa of a number.

wnnet.graph_helper.get_keywords(kw_list, **kwargs)[source]

Helper function to return keyword arguments for graph module.

wnnet.graph_helper.get_pos(coll, name, state_scaling)[source]

Helper function to define the position of a node in a network graph.

wnnet.graph_helper.get_solar_species_list()[source]

Helper function to return list of solar species.

wnnet.graph_helper.get_subset_and_anchors(nuclides)[source]

Helper function to define the scope and anchors of a graph.

wnnet.graph_helper.remove_isolated_nodes(d_g, my_args)[source]

Helper function to remove isolated nodes.

wnnet.graph_helper.set_widths_and_get_max_weight(d_g, sub_graph, my_args)[source]

Helper function to set edge widths or remove.

wnnet.net module

This module handles webnucleo nuclear reaction networks.

class wnnet.net.Net(file, nuc_xpath='', reac_xpath='')[source]

Bases: Nuc, Reac

A class to store webnucleo networks.

Args:

file (str): A string giving the name of the XML file with the network data.

nuc_xpath (str, optional): An XPath expression to select nuclides. Default is all nuclides.

reac_xpath (str, optional): An XPath expression to select reactions. Default is all reactions.

compute_q_values(nuc_xpath='', reac_xpath='')[source]

A method to compute reaction Q values for valid reactions in the network.

Args:

nuc_xpath (str, optional): An XPath expression to select the nuclides.

reac_xpath (str, optional): An XPath expression to select the reactions.

Returns:

A dict. The keys for the dictionary are the reaction strings and the values are the corresponding Q values.

compute_rates(t_9, nuc_xpath='', reac_xpath='', user_funcs='')[source]

Method to compute the forward and reverse rates for valid reactions in a network.

Args:

t_9 (float): The temperature in 109 K at which to compute the rates.

nuc_xpath (str, optional): An XPath expression to select nuclides. Default is all nuclides.

reac_xpath (str, optional): An XPath expression to select reactions. Default is all reactions.

user_funcs (dict, optional): A dictionary of user-defined functions associated with a user_rate key.

Returns:

A dict containing the rates. The key is the reaction string while the value is a two-element tuple with the first element being the forward rate and the second element being the reverse rate.

compute_rates_for_reaction(name, t_9, user_funcs='')[source]

Method to compute the forward and reverse rates for a valid reaction.

Args:

name (str): A string giving the reaction.

t_9 (float): The temperature in 109 K at which to compute the rates.

user_funcs (dict, optional): A dictionary of user-defined functions associated with a user_rate key.

Returns:

A two-element tuple with the first element being the forward rate and the second element being the reverse rate. If the reaction is not valid, returns None.

compute_reaction_q_value(name)[source]

Method to compute the Q value for a reaction.

Args:

name (str): A string giving the reaction.

Returns:

A float giving the Q value for the reaction or None if the reaction is not valid.

get_valid_reactions(nuc_xpath='', reac_xpath='')[source]

Method to retrieve the valid reactions in the network.

Args:

nuc_xpath (str, optional): An XPath expression to select nuclides. Default is all nuclides.

reac_xpath (str, optional): An XPath expression to select reactions. Default is all reactions.

Returns:

A dict of wnutils reactions.

is_valid_reaction(name, nuc_xpath='')[source]

Method to determine a reaction is valid in the network.

Args:

name (str): A string giving the reaction.

nuclides (str, optional): An XPath expression to select nuclides. Default is all nuclides.

Returns:

A bool with value True if the reaction is valid and False if not.

wnnet.nuc module

This module handles webnucleo collections of nuclides.

class wnnet.nuc.Nuc(file, nuc_xpath='')[source]

Bases: object

A class for handling nuclei and their data.

Args:

file (str): A string giving the XML file name with the nuclide data.

nuc_xpath (str, optional): An XPath expression to select nuclides. Default is all nuclides.

compute_atomic_mass(name)[source]

Method to compute the atomic mass of a species.

Args:

name (str): The name of the species.

Returns:

A float containing the atomic mass in MeV.

compute_binding_energy(name)[source]

Method to compute the nuclear binding energy of a species.

Args:

name (str): The name of the species.

Returns:

A float containing the binding energy in MeV.

compute_nse_factor(name, t_9, rho)[source]

Method to compute the NSE factor for a species.

Args:

name (str): The name of the species.

t_9 (float): The temperature in 109 K at which to compute the NSE factor.

rho (float): The density in g/cc at which to compute the NSE factor.

Returns:

A float giving the NSE factor for the species at the input conditions. This factor is the binding energy of the species divided by kT plus the logarithm of the quantum abundance of the species.

compute_nuclear_partition_function(name, t_9)[source]

Method to compute the nuclear partition function for a species.

Args:

name (str): A string giving the name of the nuclide whose partition function should be computed.

t_9 (float): The temperature in 109 K at which to compute the partition function.

Returns:

A float giving the nuclear partition function for the species at the input temperature.

compute_quantum_abundance(name, t_9, rho)[source]

Method to compute the quantum abundance of the nuclide at the input temperature and density.

Args:

name (str): The name of the species.

t_9 (float): The temperature in 109 K at which to compute the quantum abundance.

rho (float): The density in g/cc at which to compute the quantum abundance.

Returns:

A float giving the quantum abundance for the species at the input conditions.

get_nuclides(nuc_xpath='')[source]

Method to return a collection of nuclides.

Args:

nuc_xpath (str, optional): An XPath expression to select the nuclides. Default is all species in the underlying collection of nuclides.

Returns:

A dict containing wnutils nuclides.

wnnet.reac module

This module handles webnucleo collections of reactions.

class wnnet.reac.Reac(file, reac_xpath='')[source]

Bases: object

A class for handling reactions and their data.

Args:

file (str): A string giving the XML file name with the reaction data.

reac_xpath (str, optional): An XPath expression to select reactions. Default is all reactions.

compute_duplicate_factors(reac_xpath='')[source]

Method to compute the duplicate factors for reactions in the reaction collection.

Args:

reac_xpath (str, optional): An XPath expression to select reactions. Default is all reactions.

Returns:

A dict containing the factors. The keys are reaction strings. The values are two-element tuple objects with the first element the duplicate factor for the forward reaction and the second element the duplicate factor for the reverse reaction.

compute_reaction_duplicate_factors(name)[source]

Method to compute the duplicate reaction element factors for a reaction.

Args:

name (str): A string giving the reaction.

Returns:

A two-element tuple. The first element is the duplicate factor for the forward reaction. The second element is the duplicate factor for the reverse reaction.

get_reactions(reac_xpath='')[source]

Method to return a collection of reactions.

Args:

reac_xpath (str, optional): An XPath expression to select the reactions. Default is all reactions in the underlying collection of reactions.

Returns:

A dict containing wnutils reactions.

is_weak_reaction(name)[source]

Method to determine if a reaction is a weak reaction or not.

Args:

name (str): A string giving the reaction.

Returns:

A bool with value True if the reaction is a weak reaction and False if not.

wnnet.thermo module

This module computes thermodynamic quantities for data in a nuclear network.

class wnnet.thermo.Nuclei(nuc, y_cutoff=1e-25)[source]

Bases: object

A class for computing thermodynamic quantities for a collection of nuclei.

Args:

nuc (wnnet.nuc.Nuc): A wnnet nuclide collection.

y_cutoff (float, optional): The smallest abundance per nucleon to be used in thermodynamic quantity calculations.

compute_chemical_potentials(t9, rho, mass_fractions, include_rest_mass=False)[source]

Routine to compute the chemical potentials of the nuclei in units of kT.

Args:

t9 (float): The temperature in 109 K at which to compute the chemical potentials.

rho (float): The density in g/cc at which to compute the chemical potentials.

mass_fractions (float): A wnutils dictionary of mass fractions.

include_rest_mass (bool): A boolean to choose whether to include the rest mass in the

chemical potential.

Returns:

A dict with the name of each species as the key and the chemical potential (divide by kT) as the value.

compute_quantity(quantity, t9, rho, mass_fractions)[source]

Routine to compute the thermodynamic quantity for the nuclei.

Args:

quantity (str): The thermodynamic quantity to compute.

t9 (float): The temperature in 109 K at which to compute the quantity.

rho (float): The density in g/cc at which to compute the quantity.

mass_fractions (float): A wnutils dictionary of mass fractions.

Returns:

A float giving the thermo quantity in cgs units.

default_energy_density(t9, rho, mass_fractions)[source]

The default routine for computing the energy density of nuclei, which includes the rest-mass energy.

Args:

t9 (float): The temperature in 109 K at which to compute the energy density (including the rest mass).

rho (float): The density in g/cc at which to compute the energy density (including the rest mass).

mass_fractions (float): A wnutils dictionary of mass fractions.

Returns:

A float giving the energy density in cgs units.

default_entropy_density(t9, rho, mass_fractions)[source]

The default routine for computing the entropy density of nuclei.

Args:

t9 (float): The temperature in 109 K at which to compute the entropy density.

rho (float): The density in g/cc at which to compute the entropy density.

mass_fractions (float): A wnutils dictionary of mass fractions.

Returns:

A float giving the entropy density in cgs units.

default_internal_energy_density(t9, rho, mass_fractions)[source]

The default routine for computing the energy density of nuclei, which does not include the rest-mass energy.

Args:

t9 (float): The temperature in 109 K at which to compute the internal energy density.

rho (float): The density in g/cc at which to compute the internal energy density.

mass_fractions (float): A wnutils dictionary of mass fractions.

Returns:

A float giving the internal energy density in cgs units.

default_number_density(t9, rho, mass_fractions)[source]

The default routine for computing the number density of nuclei.

Args:

t9 (float): The temperature in 109 K at which to compute the number density.

rho (float): The density in g/cc at which to compute the number density.

mass_fractions (float): A wnutils dictionary of mass fractions.

Returns:

A float giving the number density in cgs units.

default_pressure(t9, rho, mass_fractions)[source]

The default routine for computing the pressure of nuclei.

Args:

t9 (float): The temperature in 109 K at which to compute the pressure.

rho (float): The density in g/cc at which to compute the pressure.

mass_fractions (float): A wnutils dictionary of mass fractions.

Returns:

A float giving the pressure in cgs units.

update_function(quantity, function)[source]

Routine to update or add a thermodynamic function for the nuclei.

Args:

quantity (str): The thermodynamic quantity.

function: A function with prototype (t9, rho, mass_fractions) to compute the thermodynamic quantity for the nuclei.

Returns:

On successful return, the function for the quantity has been updated or added.

class wnnet.thermo.Thermo(nuc)[source]

Bases: object

A class for computing thermodynamic quantities for data in a nuclear reaction network.

Args:

nuc (wnnet.nuc.Nuc): A wnnet nuclide collection.

compute_quantity(quantity, t9, rho, mass_fractions)[source]

A routine to compute a thermodynamic quantity for a given set of mass fractions at the input temperature and density.

Args:

quantity (str): The thermodynamic quantity to compute.

t9 (float): The temperature in 109 K at which to compute the quantity.

rho (float): The density in g/cc at which to compute the quantity.

mass_fractions (float): A wnutils dictionary of mass fractions.

Returns:

A dict with keys electron, photon, baryon, and total and the values being the computed quantity for each key.

compute_quantity_for_zones(quantity, zones)[source]

A routine to compute a thermodynamic quantity for the input zones.

Args:

quantity (str): The thermodynamic quantity to compute.

zones (dict): A dictionary of wnutils zone data.

Returns:

A dict with the key being the zone label and the value being another dictionary with keys electron, photon, baryon, and total and the values being the computed quantity for each zone.

compute_quantity_in_zone(quantity, zone)[source]

A routine to compute a thermodynamic quantity for the input zone.

Args:

quantity (str): The thermodynamic quantity to compute.

zone (dict): A wnutils zone.

Returns:

A dict keys electron, photon, baryon, and total and the values being the computed quantity for the zone.

get_boson(name)[source]

Routine to retrieve a boson.

Args:

name (str): The name of the boson.

Returns:

The wnstatmech boson.

get_fermion(name)[source]

Routine to retrieve a fermion.

Args:

name (str): The name of the fermion.

Returns:

The wnstatmech fermion.

get_number_density(particle)[source]

Routine to retrieve the number density for a particle. Use this routine for particles other than the default particles (photons, electrons, and nuclei). For the default particles, compute the number density directly from the compute_quantity method.

Args:

particle (str): The name of the particle.

Returns:

The number density of the particle in cgs units.

remove_boson(name)[source]

Routine to remove a boson.

Args:

name (str): The name of the boson.

Returns:

On successful return, the boson has been removed.

remove_fermion(name)[source]

Routine to remove a fermion.

Args:

name (str): The name of the fermion.

Returns:

On successful return, the fermion has been removed.

set_number_density(particle, number_density)[source]

Routine to update the number density for a particle. Use this routine to set the number density of particles other than photons, electrons, and nuclei.

Args:

particle (str): The name of the particle.

number_density (float): The number density in cgs units.

Returns:

On successful return, the number density has been updated.

update_boson(name, boson)[source]

Routine to update a boson. If the boson does not already exist, it will be added.

Args:

name (str): The name of the boson.

boson: The wnstatmech boson to update.

Returns:

On successful return, the boson has been added or updated.

update_fermion(name, fermion)[source]

Routine to update a fermion. If the fermion does not already exists, it will be added.

Args:

name (str): The name of the fermion.

fermion: The wnstatmech fermion to update.

Returns:

On successful return, the fermion has been added or updated.

wnnet.zones module

This module handles zone data from webnucleo files.

class wnnet.zones.Zones(file)[source]

Bases: object

A class for handling webnucleo zones.

Args:

file (str): A string giving the XML file name with the zone data.

get_zones(zone_xpath='')[source]

Method to return zones.

Args:

zone_xpath (str, optional): An XPath expression to select zones. Default is all zones.

Returns:

A dict of wnutils zone data objects.

write(file, pretty_print=True, zone_xpath='')[source]

Method to write the zones to an xml file.

Args:

file (str): A string giving the name of output xml file.

pretty_print (bool, optional): If set to True, routine outputs the xml in nice indented format.

zone_xpath (str, optional): An XPath expression to select zones. Default is all zones.

Returns:

On successful return, the underlying xml has been written to file.