This tutorial demonstrates how to use example codes in the libnucnet distribution examples/ directory.

Example 18: Create a collection of nuclear reactions, add reactions from data in a text file, and output the data to an xml file.

The example code is create_reac_xml_from_text.c

To run create_reac_xml_from_text, type the following on the command line:


./create_reac_xml_from_text ../data_pub/example_reac.txt ex18_output.xml

The result is ex18_output.xml

Example 19: Validate a Libnucnet__Reac input xml file against Webnucleo's schema.

The example code is validate_reac_xml.c

To run validate_reac_xml, type the following on the command line:


./validate_reac_xml ../data_pub/example_reac.xml

The result is


Valid input Libnucnet__Reac xml file!

Note you can also validate a file that uses XInclude to combine data. For example, type:


./validate_reac_xml ../data_pub/example_reac_include.xml

The result is


Valid input Libnucnet__Reac xml file!

Example 20: Create a collection of nuclear reactions from an input xml file (including via XInclude and XPointer) and output their reaction strings.

The example code is print_reactions.c

To run print_reactions, type the following on the command line:


./print_reactions ../data_pub/example_reac.xml > ex20_output.txt

The result is ex20_output.txt

You can also select out certain reactions with an xpath expression. For example, to select only (n,gamma) reactions, type:


./print_reactions ../data_pub/example_reac.xml "[ reactant = 'n' and product = 'gamma' ]" > ex20_output_xpath.txt

The result is ex20_output_xpath.txt

The input file can also use XInclude and XPointer to combine XML resources. For example, to include reactions from other XML files, print reactions from a file like the input here:


./print_reactions ../data_pub/example_reac_include.xml > ex20_include_output.txt

The result is ex20_include_output.txt

Example 21: Create a collection of nuclear reactions from an input xml file (including via XInclude and XPointer) without building a tree and output their reaction strings.

The example code is print_reactions_with_reader.c

To run print_reactions_with_reader, type the following on the command line:


./print_reactions_with_reader ../data_pub/example_reac.xml > ex21_output.txt

The result is ex21_output.txt

You can also select out certain reactions with an xpath expression. For example, to select only reactions with h1 as a reactant and he4 as a product, type:


./print_reactions_with_reader ../data_pub/example_reac.xml ".//reactant[. = 'h1' and (following-sibling::product[.='he4'] or preceding-sibling::product[.='he4'])]" > ex21_output_xpath.txt

The result is ex21_output_xpath.txt

To select reactions that have h1 as a reactant or have he4 as a product (or both conditions being true), you can type:


./print_reactions_with_reader ../data_pub/example_reac.xml ".//reactant[. = 'h1'] | .//product[. = 'he4']" > ex21_output_xpath2.txt

The result is ex21_output_xpath2.txt

The input file can also use XInclude and XPointer to combine XML resources. For example, to include reactions from other XML files, print reactions from a file like the input here:


./print_reactions_with_reader ../data_pub/example_reac_include.xml > ex21_include_output.txt

The result is ex21_include_output.txt

Example 22: Create a collection of nuclear reactions from an input xml file and print out the total number of reactions and the number in a view.

The example code is number_reactions_in_view.c

To run number_reactions_in_view, type the following on the command line:


./number_reactions_in_view ../data_pub/example_reac.xml "[reactant = 'n' and product = 'h1']" > ex22_output.txt

The result is ex22_output.txt

Example 23: Create a collection of nuclear reactions from an input xml file, remove any duplicate reactions from the NACRE data source, and output the updated data.

The example code is remove_dup_reactions.c

To run remove_dup_reactions, type the following on the command line:


./remove_dup_reactions ../data_pub/example_reac.xml ex23_output.xml

The result is ex23_output.xml

Example 24: Create a collection of nuclear reactions from an input xml file over the web, output their reaction strings, update the data from a local xml file, and output the updated data.

The example code is update_reac_data.c

To run update_reac_data, type the following on the command line:


./update_reac_data http://libnucnet.sourceforge.net/data_pub/2013-02-12/example_reac.xml ../data_pub/example_reac_new.xml "[ product = 'h2' ]" > ex24_output.txt

The result is ex24_output.txt

Example 25: Create a collection of nuclear reactions from an input xml file, update the data from a local xml file, and output the updated data to xml.

The example code is update_reac_data_to_xml.c

To run update_reac_data_to_xml, type the following on the command line:


./update_reac_data_to_xml ../data_pub/example_reac.xml ../data_pub/example_reac_new.xml ex25_output.xml

The result is ex25_output.xml

Example 26: Create a collection of nuclear reactions from an input xml file, update the data from a local xml file, and output the updated (and indented) data to xml.

The example code is update_reac_data_xml_with_text_writer.c

To run update_reac_data_xml_with_text_writer, type the following on the command line:


./update_reac_data_xml_with_text_writer ../data_pub/example_reac.xml ../data_pub/example_reac_new.xml 1 ex26_output.xml

The result is ex26_output.xml

Example 27: Create a collection of nuclear reactions from an input xml file and print out the duplicate reactant and product factors.

The example code is print_dup_factors.c

To run print_dup_factors, type the following on the command line:


./print_dup_factors ../data_pub/example_reac.xml > ex27_output.txt

The result is ex27_output.txt

You can also select out certain reactions with an xpath expression. For example, try:


./print_dup_factors ../data_pub/example_reac.xml "[ reactant = 'he4' and ( product = 'be9' or product = 'c12' ) ]" > ex27_output_xpath.txt

The result is ex27_output_xpath.txt

Example 28: Print out the reactants and products for a reaction.

The example code is print_reactants_and_products.c

To run print_reactants_and_products, type the following on the command line:


./print_reactants_and_products ../data_pub/example_reac.xml "ne28 -> na26 + n + n + electron + anti-neutrino_e" > ex28_output.txt

The result is ex28_output.txt

Example 29: Create a collection of nuclear reactions from an input xml file and print out the data for a particular reaction chosen by its reaction string.

The example code is print_reac_data_by_string.c

To run print_reac_data_by_string, type the following on the command line:


./print_reac_data_by_string ../data_pub/example_reac.xml "si28 + h1 -> p29 + gamma" > ex29_output.txt

The result is ex29_output.txt

Example 30: Create a collection of nuclear reactions from an input xml file and print out the data for a reaction or reactions chosen by an xpath expression.

The example code is print_reac_data_by_xpath.c

To print out the data for all reactions on magnesium-24, type:


./print_reac_data_by_xpath ../data_pub/example_reac.xml "[ reactant = 'mg24' ]" > ex30_output.txt

The result is ex30_output.txt

Example 31: Create a collection of nuclear reactions from an input xml file and print out the reaction rate at the input temperature.

The example code is print_rates_at_t9.c

To compute the rates at a t9 (temperature in billions of K) of 1, type:


./print_rates_at_t9 ../data_pub/example_reac.xml 1. > ex31_output.txt

The result is ex31_output.txt

This routine also can take an xpath expression. To compute the rates for all (n,gamma) rates at a t9 (temperature in billions of K) of 1, type:


./print_rates_at_t9 ../data_pub/example_reac.xml 1. "[ reactant = 'n' and product = 'gamma' ]" > ex31_output_xpath.txt

The result is ex31_output_xpath.txt

Example 32: Create a collection of nuclear reactions from an input xml file and print the rate as a function of temperature for a particular reaction chosen by its reaction string.

The example code is print_rates_by_string.c

To run print_rates_by_string, type the following on the command line:


./print_rates_by_string ../data_pub/example_reac.xml "cl35 + h1 -> ar36 + gamma" > ex32_output.txt

The result is ex32_output.txt

Example 33: Create a collection of nuclear reactions from an input xml file and print the rate as a function of temperature for a reaction or reactions chosen by an xpath expression.

The example code is print_rates_by_xpath.c

To print out the rates as a function of temperature of all reactions with oxygen-16 as a reactant, type:


./print_rates_by_xpath ../data_pub/example_reac.xml "[ reactant = 'o16' ]" > ex33_output.txt

The result is ex33_output.txt