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 21: 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 example21.c are:
- Line 70: Libnucnet__Net__is_valid_input_xml()
- Line 84: Libnucnet__Net__new_from_xml()
- Line 132: Libnucnet__Nuc__getNumberOfSpecies()
- Line 133: Libnucnet__Net__getNuc()
- Line 141: Libnucnet__Net__getReac()
- Line 150: Libnucnet__Net__getNumberOfValidReactions()
- Line 157: Libnucnet__Reac__iterateReactions()
- Line 170: Libnucnet__Reac__getNumberOfReactions()
- Line 186: Libnucnet__Net__free()
- Line 203: Libnucnet__Net__isValidReaction()
- Line 204: Libnucnet__Reaction__getString()
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 example21, type the following on the command line:
./example21 ../../data_pub/example_net.xml > ex21_output.txt
The result is ex21_output.txt
Example 22: Create a nuclear reaction network from input xml files and print the reaction Q values for the valid reactions.
libnucnet routines demonstrated in example22.c are:
- Line 65: Libnucnet__Net__new()
- Line 68: Libnucnet__Nuc__updateFromXml()
- Line 69: Libnucnet__Net__getNuc()
- Line 78: Libnucnet__Reac__updateFromXml()
- Line 79: Libnucnet__Net__getReac()
- Line 91: Libnucnet__Reac__iterateReactions()
- Line 103: Libnucnet__Net__free()
- Line 119: Libnucnet__Net__isValidReaction()
- Line 124: Libnucnet__Reaction__getString()
- Line 130: Libnucnet__Net__computeReactionQValue()
To run example22, type the following on the command line:
./example22 ../../data_pub/example_nuc.xml ../../data_pub/example_reac.xml > 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 all valid reactions at the input temperature.
libnucnet routines demonstrated in example23.c are:
- Line 76: Libnucnet__Net__new_from_xml()
- Line 132: Libnucnet__Reac__iterateReactions()
- Line 133: Libnucnet__Net__getReac()
- Line 144: Libnucnet__Net__free()
- Line 162: Libnucnet__Net__isValidReaction()
- Line 164: Libnucnet__Net__computeRatesForReaction()
- Line 176: Libnucnet__Reaction__getString()
To run example23, type the following on the command line:
./example23 ../../data_pub/example_net.xml 1. > 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 (chosen by its string) at a variety of temperatures.
libnucnet routines demonstrated in example24.c are:
- Line 64: Libnucnet__Net__new_from_xml()
- Line 71: Libnucnet__Reac__getReactionByString()
- Line 72: Libnucnet__Net__getReac()
- Line 81: Libnucnet__Net__isValidReaction()
- Line 84: Libnucnet__Reaction__getString()
- Line 92: Libnucnet__Net__computeRatesForReaction()
- Line 113: Libnucnet__Net__free()
Choose a particular reaction with a string. For example, try:
./example24 ../../data_pub/example_net.xml "c12 + he4 -> o16 + gamma" > 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 for a particular reaction or set of reactions (chosen by an xpath expression) at a variety of temperatures.
libnucnet routines demonstrated in example25.c are:
- Line 58: Libnucnet__Net__new_from_xml()
- Line 64: Libnucnet__Reac__iterateReactions()
- Line 65: Libnucnet__Net__getReac()
- Line 74: Libnucnet__Net__free()
- Line 96: Libnucnet__Net__isValidReaction()
- Line 101: Libnucnet__Reaction__getString()
- Line 109: Libnucnet__Net__computeRatesForReaction()
Choose a reaction or set of reactions with an xpath expression. For example, try:
./example25 ../../data_pub/example_net.xml "[reactant = 'ne21']" > ex25_output.txt
The result is ex25_output.txt
Example 26: 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 example26.c are:
- Line 67: Libnucnet__new()
- Line 69: Libnucnet__Nuc__updateFromXml()
- Line 70: Libnucnet__Net__getNuc()
- Line 71: Libnucnet__getNet()
- Line 78: Libnucnet__Reac__updateFromXml()
- Line 79: Libnucnet__Net__getReac()
- Line 98: Libnucnet__addZone()
- Line 104: Libnucnet__getZoneByLabels()
- Line 106: Libnucnet__Zone__computeRates()
- Line 118: Libnucnet__Reac__iterateReactions()
- Line 120: Libnucnet__Zone__getNet()
- Line 164: Libnucnet__free()
- Line 183: Libnucnet__Net__isValidReaction()
- Line 189: Libnucnet__Zone__getRatesForReaction()
- Line 194: Libnucnet__Reaction__getString()
- Line 230: Libnucnet__Zone__updateRatesForReaction()
To run example26, type the following on the command line:
./example26 ../../data_pub/example_net.xml 3. > ex26_output.txt
The result is ex26_output.txt
You can also select out certain reactions with an xpath expression. For example, try:
./example26 ../../data_pub/example_net.xml 3. "[product = 'mg25']" > ex26_xpath_output.txt
The result is ex26_xpath_output.txt
Example 27: Create a nuclear reaction network from an input xml file and for rates selected by an XPath expression, print out the forward and reverse rates, the forward screening factor, the reverse ratio correction, and the screened rates.
libnucnet routines demonstrated in example27.c are:
- Line 103: Libnucnet__Net__new_from_xml()
- Line 146: Libnucnet__Reac__iterateReactions()
- Line 147: Libnucnet__Net__getReac()
- Line 156: Libnucnet__Net__free()
- Line 171: Libnucnet__Net__isValidReaction()
- Line 173: Libnucnet__Net__computeRatesForReaction()
- Line 183: Libnucnet__Net__computeScreeningFactorForReaction()
- Line 194: Libnucnet__Net__computeReverseRatioCorrectionFactorForReaction()
- Line 205: Libnucnet__Reaction__getString()
To run example27, type the following on the command line:
./example27 ../../data_pub/example_net.xml 3. 1.e8 0.5 0.15 "[reactant = 'n15']" > ex27_output.txt
The result is ex27_output.txt
Example 28: 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 example28.c are:
- Line 62: Libnucnet__is_valid_input_xml()
- Line 71: Libnucnet__new_from_xml()
- Line 81: Libnucnet__getNumberOfZones()
- Line 90: Libnucnet__iterateZones()
- Line 102: Libnucnet__freeAllZones()
- Line 114: Libnucnet__addZone()
- Line 123: Libnucnet__Nuc__getSpeciesByName()
- Line 124: Libnucnet__Net__getNuc()
- Line 125: Libnucnet__getNet()
- Line 130: Libnucnet__Zone__updateSpeciesAbundance()
- Line 131: Libnucnet__Species__getA()
- Line 160: Libnucnet__free()
- Line 183: Libnucnet__Zone__getLabel()
- Line 191: Libnucnet__Nuc__iterateSpecies()
- Line 193: Libnucnet__Zone__getNet()
- Line 202: Libnucnet__Zone__computeAMoment()
- Line 225: Libnucnet__Zone__getSpeciesAbundance()
- Line 231: Libnucnet__Species__getName()
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 example28, type the following on the command line:
./example28 ../../data_pub/example_3d.xml > ex28_output.txt
The result is ex28_output.txt
Example 29: Create a full libnucnet structure (network plus zones) and print out data about the zones.
libnucnet routines demonstrated in example29.c are:
- Line 62: Libnucnet__new_from_xml()
- Line 69: Libnucnet__getNumberOfZones()
- Line 76: Libnucnet__iterateZones()
- Line 86: Libnucnet__free()
- Line 102: Libnucnet__Zone__getLabel()
- Line 110: Libnucnet__Nuc__iterateSpecies()
- Line 111: Libnucnet__Net__getNuc()
- Line 112: Libnucnet__Zone__getNet()
- Line 139: Libnucnet__Zone__getSpeciesAbundance()
- Line 144: Libnucnet__Species__getName()
To run example29, type the following on the command line:
./example29 ../../data_pub/example_3d.xml > ex29_output.txt
The result is ex29_output.txt
Example 30: 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 example30.c are:
- Line 63: Libnucnet__new()
- Line 65: Libnucnet__Net__updateFromXml()
- Line 66: Libnucnet__getNet()
- Line 69: Libnucnet__assignZonesFromXml()
- Line 77: Libnucnet__getZoneByLabels()
- Line 89: Libnucnet__Zone__getLabel()
- Line 98: Libnucnet__free()
- Line 112: Libnucnet__Nuc__iterateSpecies()
- Line 113: Libnucnet__Net__getNuc()
- Line 114: Libnucnet__Zone__getNet()
- Line 122: Libnucnet__Zone__computeAMoment()
- Line 137: Libnucnet__Zone__getSpeciesAbundance()
- Line 142: Libnucnet__Species__getName()
- Line 144: Libnucnet__Species__getA()
To run example30, type the following on the command line:
./example30 ../../data_pub/example_net.xml ../../data_pub/initial_mass_fractions_3d.xml x1 y1 z1 > ex30_output.txt
The result is ex30_output.txt
Example 31: 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 example31.c are:
- Line 63: Libnucnet__new_from_xml()
- Line 68: Libnucnet__new()
- Line 70: Libnucnet__Nuc__updateFromXml()
- Line 71: Libnucnet__Net__getNuc()
- Line 72: Libnucnet__getNet()
- Line 78: Libnucnet__Reac__updateFromXml()
- Line 79: Libnucnet__Net__getReac()
- Line 86: Libnucnet__assignZonesFromXml()
- Line 93: Libnucnet__Nuc__getSpeciesByName()
- Line 126: Libnucnet__iterateZones()
- Line 136: Libnucnet__free()
- Line 152: Libnucnet__Zone__getSpeciesAbundance()
- Line 157: Libnucnet__Zone__getLabel()
- Line 160: Libnucnet__Species__getA()
To run example31, type the following on the command line:
./example31 ../../data_pub/example_nuc.xml ../../data_pub/example_reac.xml ../../data_pub/initial_mass_fractions_stooges.xml he4 > ex31_output.txt
The result is ex31_output.txt
Example 32: Create a full libnucnet structure (network plus zones) and print out the screening and correction factors for the reactions in a zone.
libnucnet routines demonstrated in example32.c are:
- Line 90: Libnucnet__new_from_xml()
- Line 100: Libnucnet__getZoneByLabels()
- Line 116: Libnucnet__Zone__computeZMoment()
- Line 118: Libnucnet__Zone__setScreeningFunction()
- Line 131: Libnucnet__Zone__setNseCorrectionFactorFunction()
- Line 141: Libnucnet__Zone__computeRates()
- Line 148: Libnucnet__Zone__clearScreeningFunction()
- Line 149: Libnucnet__Zone__clearNseCorrectionFactorFunction()
- Line 160: Libnucnet__Reac__iterateReactions()
- Line 161: Libnucnet__Net__getReac()
- Line 162: Libnucnet__Zone__getNet()
- Line 175: Libnucnet__free()
- Line 190: Libnucnet__Net__isValidReaction()
- Line 199: Libnucnet__Reaction__getString()
- Line 200: Libnucnet__Zone__getScreeningFactorForReaction()
- Line 201: Libnucnet__Zone__getReverseRatioCorrectionFactorForReaction()
To run example32, type the following on the command line:
./example32 ../../data_pub/example_single_zone.xml 1. 1.e8 0 0 0 > ex32_output.txt
The result is ex32_output.txt
Example 33: Create a full libnucnet structure (network plus zones) and generate the Jacobian matrix.
libnucnet routines demonstrated in example33.c are:
- Line 100: Libnucnet__new_from_xml()
- Line 107: Libnucnet__getZoneByLabels()
- Line 119: Libnucnet__Reac__getDuplicateReactions()
- Line 120: Libnucnet__Net__getReac()
- Line 121: Libnucnet__Zone__getNet()
- Line 125: Libnucnet__Reac__iterateReactions()
- Line 131: Libnucnet__Reac__free()
- Line 144: Libnucnet__Zone__computeZMoment()
- Line 146: Libnucnet__Zone__setScreeningFunction()
- Line 159: Libnucnet__Zone__setNseCorrectionFactorFunction()
- Line 171: Libnucnet__Zone__computeRates()
- Line 178: Libnucnet__Zone__computeJacobianMatrix()
- Line 195: 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 example33, type the following on the command line:
./example33 ../../data_pub/example_single_zone.xml 0 0 0 1. 1.e3 ex33_output.txt
The result is ex33_output.txt
Example 34: 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 example34.c are:
- Line 128: Libnucnet__is_valid_input_xml()
- Line 138: Libnucnet__new_from_xml()
- Line 162: Libnucnet__getZoneByLabels()
- Line 169: Libnucnet__Reac__getDuplicateReactions()
- Line 170: Libnucnet__Net__getReac()
- Line 171: Libnucnet__Zone__getNet()
- Line 175: Libnucnet__Reac__iterateReactions()
- Line 181: Libnucnet__Reac__free()
- Line 194: Libnucnet__Zone__computeZMoment()
- Line 196: Libnucnet__Zone__setScreeningFunction()
- Line 209: Libnucnet__Zone__setNseCorrectionFactorFunction()
- Line 261: Libnucnet__Zone__updateTimeStep()
- Line 277: Libnucnet__free()
- Line 297: Libnucnet__Nuc__getNumberOfSpecies()
- Line 298: Libnucnet__Net__getNuc()
- Line 307: Libnucnet__Zone__getAbundances()
- Line 313: Libnucnet__Zone__computeRates()
- Line 325: Libnucnet__Zone__computeFlowVector()
- Line 338: Libnucnet__Zone__computeJacobianMatrix()
- Line 365: Libnucnet__Zone__updateAbundances()
- Line 396: Libnucnet__Zone__updateAbundanceChanges()
- Line 427: Libnucnet__Nuc__iterateSpecies()
- Line 438: Libnucnet__Zone__computeAMoment()
- Line 455: Libnucnet__Zone__getSpeciesAbundance()
- Line 460: Libnucnet__Species__getZ()
- Line 461: Libnucnet__Species__getA()
- Line 463: Libnucnet__Zone__getSpeciesAbundanceChange()
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:
./example34 ../../data_pub/example_single_zone.xml 0 0 0 10. 1.e8 0.1 10. 20 "[z <= 10]" > ex34_output.txt
The result is ex34_output.txt
Example 35: Create a full libnucnet structure (network plus zones) and run a single-zone network calculation but with the forward and reverse rates for a particular reaction at all temperatures multipled by a constant factor.
libnucnet routines demonstrated in example35.c are:
- Line 131: Libnucnet__is_valid_input_xml()
- Line 141: Libnucnet__new_from_xml()
- Line 165: Libnucnet__getZoneByLabels()
- Line 177: Libnucnet__Reac__getDuplicateReactions()
- Line 178: Libnucnet__Net__getReac()
- Line 179: Libnucnet__Zone__getNet()
- Line 183: Libnucnet__Reac__iterateReactions()
- Line 189: Libnucnet__Reac__free()
- Line 202: Libnucnet__Zone__computeZMoment()
- Line 204: Libnucnet__Zone__setScreeningFunction()
- Line 217: Libnucnet__Zone__setNseCorrectionFactorFunction()
- Line 268: Libnucnet__Zone__updateTimeStep()
- Line 284: Libnucnet__free()
- Line 310: Libnucnet__Nuc__getNumberOfSpecies()
- Line 311: Libnucnet__Net__getNuc()
- Line 320: Libnucnet__Zone__getAbundances()
- Line 326: Libnucnet__Zone__computeRates()
- Line 333: Libnucnet__Reac__getReactionByString()
- Line 345: Libnucnet__Zone__getRatesForReaction()
- Line 352: Libnucnet__Zone__updateRatesForReaction()
- Line 366: Libnucnet__Zone__computeFlowVector()
- Line 379: Libnucnet__Zone__computeJacobianMatrix()
- Line 406: Libnucnet__Zone__updateAbundances()
- Line 437: Libnucnet__Zone__updateAbundanceChanges()
- Line 468: Libnucnet__Nuc__iterateSpecies()
- Line 479: Libnucnet__Zone__computeAMoment()
- Line 496: Libnucnet__Zone__getSpeciesAbundance()
- Line 501: Libnucnet__Species__getZ()
- Line 502: Libnucnet__Species__getA()
- Line 504: Libnucnet__Zone__getSpeciesAbundanceChange()
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 but with the forward and reverse rates for the reaction he4 + he4 + he4 -> c12 + gamma increased by a factor of 10 at all temperatures, printing out the abundances every 20 time steps:
./example35 ../../data_pub/example_single_zone.xml 10. 1.e8 0.1 10. 20 "he4 + he4 + he4 -> c12 + gamma" 10 "[z <= 10]" > ex35_output.txt
The result is ex35_output.txt
Example 36: Create a full libnucnet structure (network plus zones) and run a multi-zone network calculation for the input conditions.
libnucnet routines demonstrated in example36.c are:
- Line 137: Libnucnet__is_valid_input_xml()
- Line 147: Libnucnet__new_from_xml()
- Line 170: Libnucnet__getNumberOfZones()
- Line 226: Libnucnet__iterateZones()
- Line 317: Libnucnet__free()
- Line 340: Libnucnet__Nuc__getNumberOfSpecies()
- Line 341: Libnucnet__Net__getNuc()
- Line 342: Libnucnet__getNet()
- Line 497: Libnucnet__Zone__getLabel()
- Line 515: Libnucnet__Nuc__iterateSpecies()
- Line 517: Libnucnet__Zone__getNet()
- Line 526: Libnucnet__Zone__computeAMoment()
- Line 541: Libnucnet__Zone__getSpeciesAbundance()
- Line 547: Libnucnet__Species__getZ()
- Line 548: Libnucnet__Species__getA()
- Line 550: Libnucnet__Zone__getSpeciesAbundanceChange()
- Line 567: Libnucnet__Zone__updateTimeStep()
- Line 594: Libnucnet__Zone__getAbundances()
- Line 640: Libnucnet__Zone__computeRates()
- Line 650: Libnucnet__Zone__computeFlowVector()
- Line 689: Libnucnet__Zone__computeJacobianMatrix()
- Line 752: Libnucnet__getZoneByLabels()
- Line 887: Libnucnet__Zone__updateAbundances()
- Line 932: Libnucnet__Zone__updateAbundanceChanges()
- Line 962: Libnucnet__Reac__getDuplicateReactions()
- Line 963: Libnucnet__Net__getReac()
- Line 968: Libnucnet__Reac__iterateReactions()
- Line 974: Libnucnet__Reac__free()
- Line 987: Libnucnet__Zone__computeZMoment()
- Line 989: Libnucnet__Zone__setScreeningFunction()
- Line 1002: Libnucnet__Zone__setNseCorrectionFactorFunction()
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:
./example36 ../../data_pub/example_1d.xml ../../data_pub/multi_zone_input.txt 0.01 100. "[z <= 10]" > ex36_output.txt
The result is ex36_output.txt
To run without mixing, use a mixing timescale of zero:
./example36 ../../data_pub/example_1d.xml ../../data_pub/multi_zone_input.txt 0. 100. "[z <= 10]" > ex36_no_mixing_output.txt
The result is ex36_no_mixing_output.txt
To run with only mixing, set all zone temperatures to zero:
./example36 ../../data_pub/example_1d.xml ../../data_pub/multi_zone_input_mixing_only.txt 0.1 100. "[z <= 10]" > ex36_mixing_only_output.txt
The result is ex36_mixing_only_output.txt