This section discusses the user interface to the AMNS subsystem.
The AMNS library is made available via a module - available versions can be found by executing
module avail amns
pkg-config --list-all | grep amns
Doxygen information about the user interface can be found here.
The AMNS library can be called from
The various bindings for the different languages are given below, but make use of a set of standard concepts which are described first.
A number of data structures are used by the library interface. Some are opaque (i.e. the contents are not of relevance to the user), and some need to be set or read by the user programme.
The two opaque types are handles which are returned by the setup routines and then need to be passed to the other routines:
In some language bindings these are the basis of classes.
The non-opaque types are:
The definitions of these data types can be found at the doxygen documentation for the AMNS User routines
The currently available reactions specified in reaction_typex%string in the call to ITM_AMNS_SETUP_TABLE are
The actual reactions are listed in the AMNS section.
The currently available queries for query%string in the call to ITM_AMNS_QUERY is
The currently available queries for query%string in the call to ITM_AMNS_QUERY_TABLE are
The currently setting options for set%string in the call to ITM_AMNS_SET is
The currently available setting options for set%string in the call to ITM_AMNS_SET_TABLE is
The fortran interface to the AMNS subsystem is based on a standardised set of calls to the AMNS library. The details of what lies behind these calls is the responsibility of the AMNS data providers and does not need to be understood by the users of the AMNS data.
The code modules devloped for the AMNS project are hosted in gforge as the project amnsproto.
The 9 calls to the AMNS system are:
subroutine ITM_AMNS_SETUP(handle, version, error_status) optional version, error_status type(amns_handle_type), intent(out) :: handle type(amns_version_type), intent(in) :: version type(amns_error_type), intent(out) :: error_status
subroutine ITM_AMNS_QUERY(handle,query,answer,error_status) optional error_status type(amns_handle_type), intent(in) :: handle type(amns_query_type), intent(in) :: query type(amns_answer_type), intent(out) :: answer type(amns_error_type), intent(out) :: error_status
subroutine ITM_AMNS_SET(handle,set,error_status) optional error_status type(amns_handle_type), intent(in) :: handle type(amns_set_type), intent(in) :: set type(amns_error_type), intent(out) :: error_status
subroutine ITM_AMNS_FINISH(handle, error_status) optional error_status type(amns_handle_type), intent(inout) :: handle type(amns_error_type), intent(out) :: error_status
subroutine ITM_AMNS_SETUP_TABLE(handle, reaction_type, reactant, handle_rx, error_status) optional error_status type(amns_handle_type), intent(in) :: handle type(amns_reaction_type), intent(in) :: reaction_type type(amns_reactants_type), intent(in) :: reactant type(amns_handle_rx_type), intent(out) :: handle_rx type(amns_error_type), intent(out) :: error_status
subroutine ITM_AMNS_QUERY_TABLE(handle_rx,query,answer,error_status) optional error_status type(amns_handle_rx_type), intent(in) :: handle_rx type(amns_query_type), intent(in) :: query type(amns_answer_type), intent(out) :: answer type(amns_error_type), intent(out) :: error_status
subroutine ITM_AMNS_SET_TABLE(handle_rx,set,error_status) optional error_status type(amns_handle_rx_type), intent(in) :: handle_rx type(amns_set_type), intent(in) :: set type(amns_error_type), intent(out) :: error_status
subroutine ITM_AMNS_FINISH_TABLE(handle_rx, error_status) optional error_status type(amns_handle_rx_type), intent(inout) :: handle_rx type(amns_error_type), intent(out) :: error_status
interface ITM_AMNS_RX module procedure ITM_AMNS_RX_1, ITM_AMNS_RX_2, ITM_AMNS_RX_3 end interface subroutine ITM_AMNS_RX_1(handle_rx,out,arg1,arg2,arg3,error_status) optional arg2,arg3,error_status type(amns_handle_rx_type), intent(inout) :: handle_rx real (kind=R8), intent(out) :: out(:) real (kind=R8), intent(in) :: arg1(:),arg2(:),arg3(:) type(amns_error_type), intent(out) :: error_status subroutine ITM_AMNS_RX_2(handle_rx,out,arg1,arg2,arg3,error_status) optional arg2,arg3,error_status type(amns_handle_rx_type), intent(inout) :: handle_rx real (kind=R8), intent(out) :: out(:,:) real (kind=R8), intent(in) :: arg1(:,:),arg2(:,:),arg3(:,:) type(amns_error_type), intent(out) :: error_status subroutine ITM_AMNS_RX_3(handle_rx,out,arg1,arg2,arg3,error_status) optional arg2,arg3,error_status type(amns_handle_rx_type), intent(inout) :: handle_rx real (kind=R8), intent(out) :: out(:,:,:) real (kind=R8), intent(in) :: arg1(:,:,:),arg2(:,:,:),arg3(:,:,:) type(amns_error_type), intent(out) :: error_status
An example of the use of the code can be found in the (fortran minimal example):
program minimal use itm_types use amns_types use amns_module 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
An example Makefile demonstrating the use of the AMNS routines:
obj/minimal: src/minimal.f90 ifort -g -o $@ $< ${shell eval-pkg-config --cflags --libs \ amns-amd64_intel_12 itmtypes-amd64_intel_12 ual-amd64_intel_12}
Other examples can be found (here):
The C interface to the AMNS subsystem is based on a standardised set of calls to the AMNS library. The details of what lies behind these calls is the responsibility of the AMNS data providers and does not need to be understood by the users of the AMNS data.
The code modules devloped for the AMNS project are hosted in gforge as the project amnsproto.
The 9 calls to the AMNS system are:
void ITM_AMNS_C_SETUP(void **handle_out, amns_error_type *error_status);
void ITM_AMNS_C_QUERY(void *handle_in, amns_query_type *query, amns_answer_type *answer, amns_error_type *error_status)
void ITM_AMNS_C_SET(void *handle_in, amns_set_type *set, amns_error_type *error_status);
void ITM_AMNS_C_FINISH(void **handle_inout, amns_error_type *error_status);
void ITM_AMNS_C_SETUP_TABLE(void *handle_in, amns_reaction_type *reaction_type, void *reactant_handle_in, void **handle_rx_out, amns_error_type *error_status);
void ITM_AMNS_C_QUERY_TABLE(void *handle_rx_in, amns_query_type *query, amns_answer_type *answer, amns_error_type *error_status);
void ITM_AMNS_C_SET_TABLE(void *handle_rx_in, amns_set_type *set, amns_error_type *error_status);
void ITM_AMNS_C_FINISH_TABLE(void **handle_rx_inout, amns_error_type *error_status);
void ITM_AMNS_C_RX_0_A(void *handle_rx_in, double *out, double arg1, amns_error_type *error_status); void ITM_AMNS_C_RX_0_B(void *handle_rx_in, double *out, double arg1, double arg2, amns_error_type *error_status); void ITM_AMNS_C_RX_0_C(void *handle_rx_in, double *out, double arg1, double arg2, double arg3, amns_error_type *error_s tatus); void ITM_AMNS_C_RX_1_A(void *handle_rx_in, int nx, double *out, double *arg1, amns_error_type *error_status); void ITM_AMNS_C_RX_1_B(void *handle_rx_in, int nx, double *out, double *arg1, double *arg2, amns_error_type *error_status); void ITM_AMNS_C_RX_1_C(void *handle_rx_in, int nx, double *out, double *arg1, double *arg2, double *arg3, amns_error_ty pe *error_status); void ITM_AMNS_C_RX_2_A(void *handle_rx_in, int nx, int ny, double *out, double *arg1, amns_error_type *error_status); void ITM_AMNS_C_RX_2_B(void *handle_rx_in, int nx, int ny, double *out, double *arg1, double *arg2, amns_error_type *error_status); void ITM_AMNS_C_RX_2_C(void *handle_rx_in, int nx, int ny, double *out, double *arg1, double *arg2, double *arg3, amns_error_type *error_status); void ITM_AMNS_C_RX_3_A(void *handle_rx_in, int nx, int ny, int nz, double *out, double *arg1, amns_error_type *error_status); void ITM_AMNS_C_RX_3_B(void *handle_rx_in, int nx, int ny, int nz, double *out, double *arg1, double *arg2, amns_error_type *error_status); void ITM_AMNS_C_RX_3_C(void *handle_rx_in, int nx, int ny, int nz, double *out, double *arg1, double *arg2, double *arg3, amns_error_type *error_status);
In addition, service routines are provided for dealing with reactants:
void ITM_AMNS_C_SETUP_REACTANTS(void **reactants_handle_out, char string_in[reaction_length], int index_in, int n_react ants); void ITM_AMNS_C_SET_REACTANT(void *reactants_handle_in, int reactant_index, amns_reactant_type *reactant_in); void ITM_AMNS_C_GET_REACTANT(void *reactants_handle_in, int reactant_index, amns_reactant_type *reactant_out); void ITM_AMNS_C_FINISH_REACTANTS(void **reactants_handle_inout);
An example of the use of the code can be found in the (c minimal example):
#include "amns_interface.h" int main(int argc, char *argv[]) { void* amns_handle = NULL; amns_c_error_type error_stat = DEFAULT_AMNS_C_ERROR_TYPE; 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=%e\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; }
An example Makefile demonstrating the use of the AMNS routines:
obj/minimal: src/minimal.c gcc -g -o $@ $< ${shell eval-pkg-config --cflags --libs\ amns-ifort itmconstants ual-amd64_intel_12}
Other examples can be found (here):
The Python interface to the AMNS subsystem is based on a standardised set of calls to the AMNS library. The details of what lies behind these calls is the responsibility of the AMNS data providers and does not need to be understood by the users of the AMNS data.
The code modules devloped for the AMNS project are hosted in gforge as the project amnsproto.
The Python interface creates
An example of the use of the code can be found in the (python minimal example):
#! /usr/bin/env python # -*- coding: utf-8 -*- import amns import numpy as np amnsdb = amns.Amns() r = amns.Reactants() r.add(6,1,12) r.add(1,0,2) r.add(6,0,12,lr=1) r.add(1,1,2,lr=1) table = amnsdb.get_table("CX", r) print "table.no_of_reactants", table.no_of_reactants print table.data(np.array([100.0]), np.array([1e20])) amnsdb.finalize()
Other examples can be found (here):