ITM AMNS: User Interface  \$Id: Doxyfile 502 2015-10-15 12:23:45Z dpc $
ITM AMNS: User Interface Documentation

AMNS User Interface Routines. The AMNS user routines provide services from the AMNS system to user codes

Author
ITM-AMNS

Documentation for the package can be found on the AMNS webpages.

Two minimal examples of using the AMNS library are given below:

Fortran example

program minimal
use itm_types
implicit none
type (amns_handle_type) :: amns ! AMNS global handle
type (amns_handle_rx_type) :: amns_rx ! AMNS table handle
type (amns_reaction_type) :: xx_rx
type (amns_reactants_type) :: species
real (kind=R8) :: te=100.0_r8, ne=1e20_r8, rate
call itm_amns_setup(amns) ! set up the AMNS system
allocate(species%components(4)) ! set up reactants
species%components = (/ amns_reactant_type(6, 1, 12, 0), amns_reactant_type(1, 0, 2, 0), amns_reactant_type(6, 0, 12, 1), amns_reactant_type(1, 1, 2, 1) /)
xx_rx%string='CX' ! set up reaction
call itm_amns_setup_table(amns, xx_rx, species, amns_rx) ! set up table
call itm_amns_rx(amns_rx, rate, te, ne) ! get results
write(*,*) 'Rate = ', rate
call itm_amns_finish_table(amns_rx) ! finish with table
call itm_amns_finish(amns) ! finish with amns
end program minimal

C example

#include "amns_interface.h"
int main(int argc, char *argv[])
{
void* amns_handle = NULL;
void* reactants_handle = NULL;
amns_c_reactant_type species1 = {.ZN=6, .ZA=1, .MI=12, .LR=0};
amns_c_reactant_type species2 = {.ZN=1, .ZA=0, .MI=2 , .LR=0};
amns_c_reactant_type species3 = {.ZN=6, .ZA=0, .MI=12, .LR=1};
amns_c_reactant_type species4 = {.ZN=1, .ZA=1, .MI=2 , .LR=1};
amns_c_reaction_type xx_rx = {.string = "CX"};
void* amns_cx_handle;
double rate;
ITM_AMNS_CC_SETUP(&amns_handle, &error_stat);
printf("error = %s: %s\n", error_stat.flag ? "true" : "false", error_stat.string);
ITM_AMNS_CC_SETUP_REACTANTS(&reactants_handle, "", 0, 4);
ITM_AMNS_CC_SET_REACTANT(reactants_handle, 1, &species1);
ITM_AMNS_CC_SET_REACTANT(reactants_handle, 2, &species2);
ITM_AMNS_CC_SET_REACTANT(reactants_handle, 3, &species3);
ITM_AMNS_CC_SET_REACTANT(reactants_handle, 4, &species4);
ITM_AMNS_CC_SETUP_TABLE(amns_handle, &xx_rx, reactants_handle, &amns_cx_handle, &error_stat);
printf("error = %s: %s\n", error_stat.flag ? "true" : "false", error_stat.string);
ITM_AMNS_CC_RX_0_B(amns_cx_handle, &rate, 100.0, 1e20, &error_stat);
printf("error = %s: %s\n", error_stat.flag ? "true" : "false", error_stat.string);
printf("Rate = %25.15e\n", rate);
ITM_AMNS_CC_FINISH_TABLE(&amns_cx_handle, &error_stat);
printf("error = %s: %s\n", error_stat.flag ? "true" : "false", error_stat.string);
ITM_AMNS_CC_FINISH_REACTANTS(&reactants_handle);
ITM_AMNS_CC_FINISH(&amns_handle, &error_stat);
printf("error = %s: %s\n", error_stat.flag ? "true" : "false", error_stat.string);
return 0;
}

Extending the AMNS Interface

Note that current interface ITM_AMNS_RX supports data that can depend on 1, 2 or 3 arguments.

Extending this to more arguments would involve:

  • adding additional optional arguments to ITM_AMNS_RX_0, ITM_AMNS_RX_1, ITM_AMNS_RX_2 and ITM_AMNS_RX_3
  • modifying the call to interpol in these routines
  • modifying interpol in data_suport if going beyond 4 arguments
  • creating additional interpolation routines if going beyond quadrilinear interpolation
  • providing the equivalent routines in amns_module_isoc.F90
  • providing the equivalent interfaces in amns_interface.h equivalent to ITM_AMNS_C_RX_0_A
  • providing the glue code equivalent in amns_interface.h equivalent to ITM_AMNS_CC_RX_0_A
  • providing the equivalent routines and interfaces for Python (in cython/)

The arguments and output all have to match in size and rank, and can be scalars, 1d, 2d or 3d arrays.

Extending this to higher rank output and arguments involves:

  • providing ITM_AMNS_RX_4, ITM_AMNS_RX_5 etc. in amns_module.F90
  • providing the equivalent routines in amns_module_isoc.F90
  • providing the equivalent interfaces in amns_interface.h equivalent to ITM_AMNS_C_RX_0_A
  • providing the glue code equivalent in amns_interface.h equivalent to ITM_AMNS_CC_RX_0_A
  • providing the equivalent routines and interfaces for Python (in cython/)