Warning: This is no longer the latest available version of this module. Please see the releases page for the most recent version. The Webnucleo group strongly recommends the use of the latest version of any of its online modules.
This tutorial demonstrates how to use example codes in the libnucnet distribution src/examples directory. The sample input files used in the tutorial are included in the distribution release and may be located in the data_pub directory.
Example 20: Create a nuclear reaction network from an input xml file and print the valid reactions (those between nuclei in the network) and the invalid reactions (those between nuclei not in the network).
libnucnet routines demonstrated in example20.c are:
- Line 86: Libnucnet__Net__is_valid_input_xml()
- Line 100: Libnucnet__Net__new_from_xml()
- Line 148: Libnucnet__Nuc__getNumberOfSpecies()
- Line 149: Libnucnet__Net__getNuc()
- Line 157: Libnucnet__Net__getReac()
- Line 164: Libnucnet__Net__getNumberOfValidReactions()
- Line 171: Libnucnet__Reac__getFirstReaction()
- Line 175: Libnucnet__Net__isValidReaction()
- Line 176: Libnucnet__Reaction__getString()
- Line 178: Libnucnet__Reaction__getNext()
- Line 187: Libnucnet__Reac__getNumberOfReactions()
- Line 208: Libnucnet__Net__free()
The first thing you need to do is to merge the nuclear data xml file and the reaction data xml file into a single network data xml file. Use xsltproc (which you should have installed as described in the compile tutorial):
xsltproc --stringparam reac_doc ../data_pub/example_reac.xml ../../xsl_pub/merge_net.xsl ../../data_pub/example_nuc.xml > ../../data_pub/example_net.xml
To run example20, type the following on the command line:
example20 ../../data_pub/example_net.xml > ex20_output.txt
The result is ex20_output.txt
Example 21: Create a nuclear reaction network from input xml files and print the reaction Q values for the valid reactions.
libnucnet routines demonstrated in example21.c are:
- Line 87: Libnucnet__Net__new()
- Line 90: Libnucnet__Nuc__updateFromXml()
- Line 91: Libnucnet__Net__getNuc()
- Line 100: Libnucnet__Reac__updateFromXml()
- Line 101: Libnucnet__Net__getReac()
- Line 116: Libnucnet__Reac__getFirstReaction()
- Line 122: Libnucnet__Net__isValidReaction()
- Line 125: Libnucnet__Reaction__getString()
- Line 128: Libnucnet__Net__calculateReactionQValue()
- Line 134: Libnucnet__Reaction__getNext()
- Line 142: Libnucnet__Net__free()
To run example21, type the following on the command line:
example21 ../../data_pub/example_nuc.xml ../../data_pub/example_reac.xml > ex21_output.txt
The result is ex21_output.txt
Example 22: Create a nuclear reaction network from an input xml file and print the forward and reverse rates for all valid reactions at the input temperature.
libnucnet routines demonstrated in example22.c are:
- Line 93: Libnucnet__Net__new_from_xml()
- Line 144: Libnucnet__Reac__getFirstReaction()
- Line 145: Libnucnet__Net__getReac()
- Line 150: Libnucnet__Net__isValidReaction()
- Line 152: Libnucnet__Net__computeRatesForReaction()
- Line 157: Libnucnet__Reaction__getString()
- Line 163: Libnucnet__Reaction__getNext()
- Line 171: Libnucnet__Net__free()
To run example22, type the following on the command line:
example22 ../../data_pub/example_net.xml 1. > ex22_output.txt
The result is ex22_output.txt
Example 23: Create a nuclear reaction network from an input xml file and print the forward and reverse rates for a particular reaction (chosen by its string) at a variety of temperatures.
libnucnet routines demonstrated in example23.c are:
- Line 87: Libnucnet__Net__new_from_xml()
- Line 94: Libnucnet__Reac__getReactionByString()
- Line 95: Libnucnet__Net__getReac()
- Line 104: Libnucnet__Net__isValidReaction()
- Line 107: Libnucnet__Reaction__getString()
- Line 115: Libnucnet__Net__computeRatesForReaction()
- Line 136: Libnucnet__Net__free()
Choose a particular reaction with a string. For example, try:
example23 ../../data_pub/example_net.xml "c12 + he4 -> o16 + gamma" > ex23_output.txt
The result is ex23_output.txt
Example 24: Create a nuclear reaction network from an input xml file and print the forward and reverse rates for a particular reaction or set of reactions (chosen by an xpath expression) at a variety of temperatures.
libnucnet routines demonstrated in example24.c are:
- Line 87: Libnucnet__Net__new_from_xml()
- Line 94: Libnucnet__Reac__getFirstReaction()
- Line 95: Libnucnet__Net__getReac()
- Line 100: Libnucnet__Net__isValidReaction()
- Line 103: Libnucnet__Reaction__getString()
- Line 111: Libnucnet__Net__computeRatesForReaction()
- Line 123: Libnucnet__Reaction__getNext()
- Line 131: Libnucnet__Net__free()
Choose a reaction or set of reactions with an xpath expression. For example, try:
example24 ../../data_pub/example_net.xml "[reactant = 'ne21']" > ex24_output.txt
The result is ex24_output.txt
Example 25: Create a nuclear reaction network from an input xml file and print the forward and reverse rates at the input temperature and then double the rates and print them out again.
libnucnet routines demonstrated in example25.c are:
- Line 87: Libnucnet__new_from_xml()
- Line 100: Libnucnet__getFirstZone()
- Line 106: Libnucnet__Zone__computeRates()
- Line 119: Libnucnet__Reac__getFirstReaction()
- Line 120: Libnucnet__Net__getReac()
- Line 121: Libnucnet__Zone__getNet()
- Line 128: Libnucnet__Net__isValidReaction()
- Line 134: Libnucnet__Reaction__getNext()
- Line 139: Libnucnet__Zone__getRatesForReaction()
- Line 144: Libnucnet__Reaction__getString()
- Line 185: Libnucnet__Zone__replaceRatesForReaction()
- Line 242: Libnucnet__free()
To run example25, type the following on the command line:
example25 ../../data_pub/example_net.xml 3. > ex25_output.txt
The result is ex25_output.txt
You can also select out certain reactions with an xpath expression. For example, try:
example25 ../../data_pub/example_net.xml 3. "[product = 'mg25']" > ex25_xpath_output.txt
The result is ex25_xpath_output.txt
Example 26: Create a full libnucnet nuclear reaction network structure (nuclei plus reactions among them) from an input xml file print out data about the input zones, remove the zones, and add a zone.
libnucnet routines demonstrated in example26.c are:
- Line 80: Libnucnet__is_valid_input_xml()
- Line 89: Libnucnet__new_from_xml()
- Line 97: Libnucnet__getNumberOfZones()
- Line 104: Libnucnet__getFirstZone()
- Line 110: Libnucnet__Zone__getLabel()
- Line 118: Libnucnet__Zone__getNext()
- Line 128: Libnucnet__freeAllZones()
- Line 140: Libnucnet__addZone()
- Line 144: Libnucnet__Nuc__getSpeciesByName()
- Line 145: Libnucnet__Net__getNuc()
- Line 149: Libnucnet__Zone__addSpecies()
- Line 188: Libnucnet__free()
- Line 204: Libnucnet__Nuc__getFirstSpecies()
- Line 206: Libnucnet__Zone__getNet()
- Line 218: Libnucnet__Zone__getSpeciesAbundance()
- Line 223: Libnucnet__Species__getName()
- Line 225: Libnucnet__Species__getA()
- Line 230: Libnucnet__Species__getNext()
The first thing you need to do is to merge the nuclear network xml file and an input mass fractions data xml file into a single xml file appropriate as a libnucnet input file. Use xsltproc (which you should have installed during the compilation tutorial):
xsltproc --stringparam initial_mass_frac_doc ../data_pub/initial_mass_fractions_3d.xml ../../xsl_pub/merge_full.xsl ../../data_pub/example_net.xml > ../../data_pub/example_3d.xml
To run example26, type the following on the command line:
example26 ../../data_pub/example_3d.xml > ex26_output.txt
The result is ex26_output.txt
Example 27: Create a full libnucnet structure (network plus zones) and print out data about the zones.
libnucnet routines demonstrated in example27.c are:
- Line 77: Libnucnet__new_from_xml()
- Line 85: Libnucnet__getNumberOfZones()
- Line 92: Libnucnet__getFirstZone()
- Line 99: Libnucnet__Zone__getLabel()
- Line 105: Libnucnet__Nuc__getFirstSpecies()
- Line 106: Libnucnet__Net__getNuc()
- Line 107: Libnucnet__Zone__getNet()
- Line 117: Libnucnet__Zone__getSpeciesAbundance()
- Line 122: Libnucnet__Species__getName()
- Line 126: Libnucnet__Species__getNext()
- Line 132: Libnucnet__Zone__getNext()
- Line 140: Libnucnet__free()
To run example27, type the following on the command line:
example27 ../../data_pub/example_3d.xml > ex27_output.txt
The result is ex27_output.txt
Example 28: Create a full libnucnet structure (network plus zones) and print out initial mass fractions for a zone chosen by its labels.
libnucnet routines demonstrated in example28.c are:
- Line 84: Libnucnet__new()
- Line 86: Libnucnet__Net__updateFromXml()
- Line 87: Libnucnet__getNet()
- Line 90: Libnucnet__assignZonesFromXml()
- Line 98: Libnucnet__getZoneByLabels()
- Line 110: Libnucnet__Zone__getLabel()
- Line 119: Libnucnet__free()
- Line 134: Libnucnet__Nuc__getFirstSpecies()
- Line 135: Libnucnet__Net__getNuc()
- Line 136: Libnucnet__Zone__getNet()
- Line 148: Libnucnet__Zone__getSpeciesAbundance()
- Line 153: Libnucnet__Species__getName()
- Line 155: Libnucnet__Species__getA()
- Line 160: Libnucnet__Species__getNext()
To run example28, type the following on the command line:
example28 ../../data_pub/example_net.xml ../../data_pub/initial_mass_fractions_3d.xml x1 y1 z1 > ex28_output.txt
The result is ex28_output.txt
Example 29: Create a full libnucnet structure (network plus zones) and print out initial mass fractions for a given species in all zones.
libnucnet routines demonstrated in example29.c are:
- Line 86: Libnucnet__new_from_xml()
- Line 91: Libnucnet__new()
- Line 93: Libnucnet__Nuc__updateFromXml()
- Line 94: Libnucnet__Net__getNuc()
- Line 95: Libnucnet__getNet()
- Line 101: Libnucnet__Reac__updateFromXml()
- Line 102: Libnucnet__Net__getReac()
- Line 109: Libnucnet__assignZonesFromXml()
- Line 116: Libnucnet__Nuc__getSpeciesByName()
- Line 146: Libnucnet__getFirstZone()
- Line 151: Libnucnet__Zone__getSpeciesAbundance()
- Line 155: Libnucnet__Zone__getLabel()
- Line 158: Libnucnet__Species__getA()
- Line 161: Libnucnet__Zone__getNext()
- Line 171: Libnucnet__free()
- Line 86: Libnucnet__new_from_xml()
- Line 91: Libnucnet__new()
- Line 93: Libnucnet__Nuc__updateFromXml()
- Line 94: Libnucnet__Net__getNuc()
- Line 95: Libnucnet__getNet()
- Line 101: Libnucnet__Reac__updateFromXml()
- Line 102: Libnucnet__Net__getReac()
- Line 109: Libnucnet__assignZonesFromXml()
- Line 116: Libnucnet__Nuc__getSpeciesByName()
- Line 146: Libnucnet__getFirstZone()
- Line 151: Libnucnet__Zone__getSpeciesAbundance()
- Line 155: Libnucnet__Zone__getLabel()
- Line 158: Libnucnet__Species__getA()
- Line 161: Libnucnet__Zone__getNext()
- Line 171: Libnucnet__free()
To run example29, type the following on the command line:
example29 ../../data_pub/example_nuc.xml ../../data_pub/example_reac.xml ../../data_pub/initial_mass_fractions_stooges.xml he4 > ex29_output.txt
The result is ex29_output.txt
Example 30: Create a full libnucnet structure (network plus zones) and generate the Jacobian matrix.
libnucnet routines demonstrated in example30.c are:
- Line 85: Libnucnet__new_from_xml()
- Line 91: Libnucnet__getFirstZone()
- Line 97: Libnucnet__Zone__computeRates()
- Line 104: Libnucnet__Zone__getJacobianMatrix()
- Line 121: Libnucnet__free()
The first thing you need to do is to merge the nuclear network xml file and an input mass fractions data xml file appropriate for a single zone calculation into a single xml file appropriate as a libnucnet input file. Use xsltproc (which you should have installed during the compilation tutorial):
xsltproc --stringparam initial_mass_frac_doc ../data_pub/initial_mass_fractions_single_zone.xml ../../xsl_pub/merge_full.xsl ../../data_pub/example_net.xml > ../../data_pub/example_single_zone.xml
To run example30, type the following on the command line:
example30 ../../data_pub/example_single_zone.xml 1. 1.e3 ex30_output.txt
The result is ex30_output.txt
Example 31: Create a full libnucnet structure (network plus zones) and run a single-zone network calculation for the input temperature, density, and duration.
libnucnet routines demonstrated in example31.c are:
- Line 124: Libnucnet__is_valid_input_xml()
- Line 134: Libnucnet__new_from_xml()
- Line 159: Libnucnet__getFirstZone()
- Line 199: Libnucnet__Zone__updateTimeStep()
- Line 215: Libnucnet__free()
- Line 235: Libnucnet__Nuc__getNumberOfSpecies()
- Line 236: Libnucnet__Net__getNuc()
- Line 237: Libnucnet__Zone__getNet()
- Line 252: Libnucnet__Nuc__getFirstSpecies()
- Line 259: Libnucnet__Species__getIndex()
- Line 261: Libnucnet__Zone__getSpeciesAbundance()
- Line 262: Libnucnet__Species__getNext()
- Line 269: Libnucnet__Zone__computeRates()
- Line 281: Libnucnet__Zone__getFlowVector()
- Line 306: Libnucnet__Zone__getJacobianMatrix()
- Line 339: Libnucnet__Zone__updateSpeciesAbundance()
- Line 435: Libnucnet__Species__getA()
- Line 437: Libnucnet__Species__getZ()
Use a network of nuclei with Z <= 10 and compute the evolution of the abundances of species with initial abundances in the input file at an initial T9 = 10 and density of 1.e8 g/cc expanding with a density e-folding timescale of 0.1 seconds for 10 seconds, printing out the abundances every 20 time steps:
example31 ../../data_pub/example_single_zone.xml 10. 1.e8 0.1 10. 20 "[z <= 10]" > ex31_output.txt
The result is ex31_output.txt
Example 32: Create a full libnucnet structure (network plus zones) and run a multi-zone network calculation for the input conditions.
libnucnet routines demonstrated in example32.c are:
- Line 119: Libnucnet__is_valid_input_xml()
- Line 129: Libnucnet__new_from_xml()
- Line 152: Libnucnet__getNumberOfZones()
- Line 248: Libnucnet__getFirstZone()
- Line 253: Libnucnet__Zone__getLabel()
- Line 260: Libnucnet__Zone__getNext()
- Line 272: Libnucnet__Zone__updateTimeStep()
- Line 312: Libnucnet__free()
- Line 340: Libnucnet__Nuc__getNumberOfSpecies()
- Line 341: Libnucnet__Net__getNuc()
- Line 342: Libnucnet__getNet()
- Line 363: Libnucnet__Nuc__getFirstSpecies()
- Line 370: Libnucnet__Species__getIndex()
- Line 372: Libnucnet__Zone__getSpeciesAbundance()
- Line 373: Libnucnet__Species__getNext()
- Line 403: Libnucnet__Zone__computeRates()
- Line 409: Libnucnet__Zone__getFlowVector()
- Line 439: Libnucnet__Zone__getJacobianMatrix()
- Line 498: Libnucnet__Zone__getPrevious()
- Line 607: Libnucnet__Zone__updateSpeciesAbundance()
- Line 687: Libnucnet__Zone__getNet()
- Line 695: Libnucnet__Species__getA()
- Line 700: Libnucnet__Species__getZ()
The first thing you need to do is to merge the nuclear network xml file and an input mass fractions data xml file appropriate for a 1-D multi-zone calculation into a single xml file appropriate as a libnucnet input file. Use xsltproc (which you should have installed during the compilation tutorial):
xsltproc --stringparam initial_mass_frac_doc ../data_pub/initial_mass_fractions_1d.xml ../../xsl_pub/merge_full.xsl ../../data_pub/example_net.xml > ../../data_pub/example_1d.xml
For a network of nuclei with Z <= 10, compute the evolution of the abundances of species in the three input zones for a duration of 100 seconds with a mixing time between zones of 0.01 seconds:
example32 ../../data_pub/example_1d.xml ../../data_pub/multi_zone_input.txt 0.01 100. "[z <= 10]" > ex32_output.txt
The result is ex32_output.txt