1 /*//////////////////////////////////////////////////////////////////////////////
2 //
10 //
11 // See the README.txt file in this directory for copyright and license
12 // information.
13 //
14 //
15 //
16 // Example to demonstrate how to use libnucnet routines to create a
17 // Libnucnet__Nuc structure of nuclear species from an input xml
18 // file, print out the nuclear partition function for a species
19 // selected by its Z, A, and state, and clear the structure and free the
20 // allocated memory.
21 //
22 //
23 //
24 //////////////////////////////////////////////////////////////////////////////*/
25
26 #include
27
28 int main( int argc, char * argv[] ) {
29
30 Libnucnet__Nuc *p_my_nuclei;
31 Libnucnet__Species *p_species;
32 unsigned int i, i_z, i_a;
33 double d_t9;
34
35 /* Check input */
36
37 if ( (argc < 4) | (argc > 5) ) {
38 fprintf(
39 stderr, "\nUsage: %s filename Z A State\n\n", argv[0]
40 );
41 fprintf(
42 stderr, " filename = input nuclear data xml filename or url\n\n"
43 );
44 fprintf(
45 stderr, " Z = Z of species\n\n"
46 );
47 fprintf(
48 stderr, " A = A of species\n\n"
49 );
50 fprintf(
51 stderr, " State = State of species (optional)\n\n"
52 );
53 return EXIT_FAILURE;
54 }
55
56 /*============================================================================
57 // Get network from input xml file.
58 //==========================================================================*/
59
60 p_my_nuclei = Libnucnet__Nuc__new_from_xml( argv[1], NULL );
61
62 /*============================================================================
63 // Get species index and name.
64 //==========================================================================*/
65
66 i_z = atoi( argv[2] );
67 i_a = atoi( argv[3] );
68
69 if( !argv[4] ) {
70 p_species = Libnucnet__Nuc__getSpeciesByZA(
71 p_my_nuclei, i_z, i_a, NULL
72 );
73 } else {
74 p_species = Libnucnet__Nuc__getSpeciesByZA(
75 p_my_nuclei, i_z, i_a, argv[4]
76 );
77 }
78
79 /*============================================================================
80 // Exit if species not present.
81 //==========================================================================*/
82
83 if( !p_species ) {
84 fprintf( stderr, "Species not present in network!\n" );
85 Libnucnet__Nuc__free( p_my_nuclei );
86 return EXIT_FAILURE;
87 }
88
89 /*============================================================================
90 // Print out partition function if species present in network.
91 //==========================================================================*/
92
93 printf( "\nFor %s\n\n", Libnucnet__Species__getName( p_species ) );
94
95 printf( " t9 Partition Function\n" );
96 printf( " ------ ------------------\n\n" );
97
98 for( i = 0; i < 31; i++ ) {
99 d_t9 = pow( 10., -1 + ( (float) i ) /10. );
100 printf(" %8.4f %15.4e\n", d_t9,
101 Libnucnet__Species__computePartitionFunction(
102 p_species, d_t9 )
103 );
104 }
105
106 /*============================================================================
107 // Clean up and exit.
108 //==========================================================================*/
109
110 Libnucnet__Nuc__free( p_my_nuclei );
111
112 return EXIT_SUCCESS;
113
114 }