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 17 // a new Libnucnet__Reac structure of nuclear reactions from an 18 // input xml file, print out the rate for a reaction chosen by 19 // its reaction string at a variety of temperatures, and clear 20 // the structure and free the allocated memory. 21 // 22 // 23 // 24 //////////////////////////////////////////////////////////////////////////////*/ 25 26 27 #include 28 29 int main( int argc, char * argv[] ) { 30 31 Libnucnet__Reac *p_my_reactions; 32 Libnucnet__Reaction *p_reaction; 33 34 double a_t9[23] = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.5, 35 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 6.0, 7.0, 8.0, 9.0, 36 10.0 37 }; 38 int i_temp; 39 40 /*============================================================================ 41 // Check input. 42 //==========================================================================*/ 43 44 if ( argc!= 3 ) { 45 fprintf( 46 stderr, "\nUsage: %s filename string\n\n", argv[0] 47 ); 48 fprintf( 49 stderr, " net_filename = input nuclear data xml filename\n\n" 50 ); 51 fprintf( 52 stderr, " string = reaction string\n\n" 53 ); 54 55 return EXIT_FAILURE; 56 } 57 58 /*============================================================================ 59 // Read input file. 60 //==========================================================================*/ 61 62 p_my_reactions = Libnucnet__Reac__new_from_xml( argv[1], NULL ); 63 64 /*============================================================================ 65 // Compute rates. 66 //==========================================================================*/ 67 68 p_reaction = Libnucnet__Reac__getReactionByString( p_my_reactions, argv[2] ); 69 70 if( p_reaction ) { 71 72 printf( "\n%s\n\n", 73 Libnucnet__Reaction__getString( p_reaction ) 74 ); 75 76 printf( "T9(K)\t\t Rate\n" ); 77 printf( "=====\t\t============\n" ); 78 79 for ( i_temp = 0; i_temp < 23; i_temp++ ) { 80 81 printf( " %1.1f\t\t%e\n", 82 a_t9[i_temp], 83 Libnucnet__Reaction__computeRate( 84 p_reaction, a_t9[i_temp] 85 ) 86 ); 87 88 } 89 90 } 91 else 92 { 93 Libnucnet__Reac__free( p_my_reactions ); 94 fprintf( stderr, "Reaction not found!\n" ); 95 return EXIT_FAILURE; 96 } 97 98 /*============================================================================ 99 // Clean up and exit. 100 //==========================================================================*/ 101 102 Libnucnet__Reac__free( p_my_reactions ); 103 104 return EXIT_SUCCESS; 105 106 } 107