This tutorial demonstrates how to use example codes in the libnucnet distribution examples/ directory.
Example 1: Create a collection of nuclei, add species, and remove them.
The example code is create_nuc_collection.c
To run create_nuc_collection, type the following on the command line:
./create_nuc_collection > ex1_output.txt
The result is ex1_output.txt
Example 2: Create a collection of nuclei, add species, and write data to an xml file.
The example code is create_nuc_xml_from_text.c
To run create_nuc_xml_from_text, type the following on the command line:
./create_nuc_xml_from_text ../data_pub/example_nuc.txt ex2_output.xml
The result is ex2_output.xml
Example 3: Validate a Libnucnet__Nuc input xml file against Webnucleo's schema.
The example code is validate_nuc_xml.c
To run validate_nuc_xml, type the following on the command line:
./validate_nuc_xml ../data_pub/example_nuc.xml
The result is
Valid input Libnucnet__Nuc xml file!
To validate a file that uses XInclude, type:
./validate_nuc_xml ../data_pub/example_nuc_include.xml
The result is
Valid input Libnucnet__Nuc xml file!
To see what happens when the input xml is invalid (the following input file has a negative mass number for the neutron), type:
./validate_nuc_xml ../data_pub/example_nuc_wrong.xml
The result is
../data_pub/example_nuc_wrong.xml:11: element a: Schemas validity error : Element 'a': '-1' is not a valid value of the atomic type '{http://libnucnet.sourceforge.net/xsd_pub/2014-12-13/libnucnet__nuc__types/}a_type'.
Example 4: Create a collection of nuclei from an input xml file and output the data about each species.
The example code is print_nuclides.c
To run print_nuclides, type the following on the command line:
./print_nuclides ../data_pub/example_nuc.xml > ex4_output.txt
The result is ex4_output.txt
You can also select out certain species with an xpath expression. For example, to select only isotopes of elements between and including neon and calcium, type:
./print_nuclides ../data_pub/example_nuc.xml "[ z >= 10 and z <= 20 ]" > ex4_output_xpath.txt
The result is ex4_output_xpath.txt
Note you can also read data over the web. For example, to select data from the original example xml file residing at sourceforge, type:
./print_nuclides http://libnucnet.sourceforge.net/data_pub/2013-02-12/example_nuc.xml > ex4_web_output.txt
The result is ex4_web_output.txt
Finally, note you can also read data that is combined from multiple files using XInclude. For example, type:
./print_nuclides ../data_pub/example_nuc_include.xml > ex4_include_output.txt
The result is ex4_include_output.txt
Example 5: Create a collection of nuclei from an input xml file without building a tree and output the data about each species.
The example code is print_nuclides_with_reader.c
To run print_nuclides_with_reader, type the following on the command line:
./print_nuclides_with_reader ../data_pub/example_nuc.xml > ex5_output.txt
The result is ex5_output.txt
You can also select out certain species with an xpath expression. For example, to select only isotopes of elements between and including neon and calcium, type:
./print_nuclides_with_reader ../data_pub/example_nuc.xml ".//z[ . >= 10 and . <= 20 ]" > ex5_output_xpath.txt
The result is ex5_output_xpath.txt
Note you can also read data over the web. For example, to select data from the original example xml file residing at sourceforge, type:
./print_nuclides_with_reader http://libnucnet.sourceforge.net/data_pub/2013-02-12/example_nuc.xml > ex5_web_output.txt
The result is ex5_web_output.txt
Finally, note you can also read data that is combined from multiple files using XInclude. For example, type:
./print_nuclides_with_reader ../data_pub/example_nuc_include.xml > ex5_include_output.txt
The result is ex5_include_output.txt
Example 6: Create a latex table of the species in a nuclide collection.
The example code is create_nuclide_latex_table.c
To run create_nuclide_latex_table, type the following on the command line:
./create_nuclide_latex_table ../data_pub/example_nuc.xml ex6_output.tex
The result is ex6_output.tex
Example 7: Create a collection of nuclei from an input xml file and output the largest Z, N, and A in the network.
The example code is print_largest_nucleon_numbers.c
To run print_largest_nucleon_numbers, type the following on the command line:
./print_largest_nucleon_numbers ../data_pub/example_nuc.xml > ex7_output.txt
The result is ex7_output.txt
You can also select out certain species with an xpath expression. For example, to select only isotopes of elements up to calcium:
./print_largest_nucleon_numbers ../data_pub/example_nuc.xml "[ z <= 20 ]" > ex7_output_xpath.txt
The result is ex7_output_xpath.txt
Example 8: Sort the species in a collection of nuclei according to a user-supplied function.
The example code is sort_nuclides.c
To run sort_nuclides, type the following on the command line:
./sort_nuclides ../data_pub/example_nuc.xml > ex8_output.txt
The result is ex8_output.txt
Example 9: Change the data for selected isotopes in a collection using a view.
The example code is modify_nuc.c
To run modify_nuc, type the following on the command line:
./modify_nuc ../data_pub/example_nuc.xml "[z = 10]" 1.5 > ex9_output.txt
The result is ex9_output.txt
Example 10: Print masses, binding energies, and separation energies of species in a nuclear collection.
The example code is print_nuclear_energies.c
To run print_nuclear_energies, type the following on the command line:
./print_nuclear_energies ../data_pub/example_nuc.xml > ex10_output.txt
The result is ex10_output.txt
To output energies for nuclei only with neutron number 22, type:
./print_nuclear_energies ../data_pub/example_nuc.xml "[a = 1 or (a - z) = 22]" > ex10_output_xpath.txt
The result is ex10_output_xpath.txt
Example 11: Create a collection of nuclei from an input xml file and output a subset chosen by an xpath expression to a new file. Indent the output xml.
The example code is extract_nuc_subset.c
To output data about nuclei in the input file with atomic number less than or equal to 10, type:
./extract_nuc_subset ../data_pub/example_nuc.xml "[z <= 10]" 1 ex11_output.xml
The result is ex11_output.xml
Example 12: Create a collection of nuclei from data read over the web, output the data, modify the nuclear data with data from a local file, and output the updated data.
The example code is update_nuc_data.c
To modify data for Z < 5 from the original Webnucleo.org nuclear data file with data from a local file (the changes are modified data for beryllium-7 and the addition of carbon 12), type at the command line:
./update_nuc_data http://libnucnet.sourceforge.net/data_pub/2013-02-12/example_nuc.xml ../data_pub/example_nuc_new.xml "[ z < 5 ]" > ex12_output.txt
The result is ex12_output.txt
Example 13: Create a collection of nuclei from an input xml file and print out data about a particular species selected by its name.
The example code is print_nuc_data_by_name.c
To run print_nuc_data_by_name, type the following on the command line:
./print_nuc_data_by_name ../data_pub/example_nuc.xml si28 > ex13_output.txt
The result is ex13_output.txt
Example 14: Create a collection of nuclei from an input xml file and output data about a particular species selected by its charge, mass, and state.
The example code is print_nuc_data_by_z_and_a.c
To run print_nuc_data_by_z_and_a, type the following on the command line:
./print_nuc_data_by_z_and_a ../data_pub/example_nuc.xml 13 27 > ex14_output.txt
The result is ex14_output.txt
When there are multiple states present for the isotope, select them by their state index (for example, g or m):
./print_nuc_data_by_z_and_a ../data_pub/example_nuc.xml 13 26 m > ex14_state_output.txt
The result is ex14_state_output.txt
Example 15: Create a collection of nuclei from an input xml file and print out the species that have multiple states.
The example code is print_multi_state_species.c
To run print_multi_state_species, type the following on the command line:
./print_multi_state_species ../data_pub/example_nuc.xml > ex15_output.txt
The result is ex15_output.txt
Example 16: Create a collection of nuclei from an input xml file and print out the nuclear partition function for a particular species selected by its name.
The example code is compute_partf_by_name.c
To run compute_partf_by_name, type the following on the command line:
./compute_partf_by_name ../data_pub/example_nuc.xml ca42 > ex16_output.txt
The result is ex16_output.txt
Example 17: Create a collection of nuclei from an input xml file and print out the nuclear partition function for a particular species selected by its charge, mass, and state.
The example code is compute_partf_by_z_and_a.c
To run compute_partf_by_z_and_a, type the following on the command line:
./compute_partf_by_z_and_a ../data_pub/example_nuc.xml 13 27 > ex17_output.txt
The result is ex17_output.txt
When there are multiple states present for the isotope, select them by their state index (for example, g or m):
./compute_partf_by_z_and_a ../data_pub/example_nuc.xml 13 26 m > ex17_state_output.txt
The result is ex17_state_output.txt