star-line

Structure for accelerating line importance sampling
git clone git://git.meso-star.fr/star-line.git
Log | Files | Refs | README | LICENSE

commit bafd3efb0869bb1da4762b89f5b7304831d3b280
parent 345d66bad759bd3b7ddbe6fc76740655ab30f1c4
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 27 Apr 2022 11:23:35 +0200

Register the molecule parameters of the tree

i.e. concentration, cutoff and isotope abundances. Map them to the
molecule id and the isotope local id.

Diffstat:
Msrc/sln_tree.c | 60+++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
Msrc/sln_tree_c.h | 11+++++++++++
2 files changed, 66 insertions(+), 5 deletions(-)

diff --git a/src/sln_tree.c b/src/sln_tree.c @@ -23,6 +23,11 @@ #include <star/shtr.h> +STATIC_ASSERT(SLN_MAX_MOLECULES_COUNT <= SHTR_MAX_MOLECULES_COUNT, + Invalid_SLN_MAX_MOLECULES_COUNT); +STATIC_ASSERT(SLN_MAX_ISOTOPES_COUNT <= SHTR_MAX_ISOTOPES_COUNT, + Invalid_SLN_MAX_ISOTOPES_COUNT); + /******************************************************************************* * Helper functions ******************************************************************************/ @@ -204,11 +209,6 @@ create_lines_view const struct sln_tree_create_args* tree_args, struct shtr_lines_view** out_view) { - STATIC_ASSERT(SLN_MAX_MOLECULES_COUNT <= SHTR_MAX_MOLECULES_COUNT, - Invalid_SLN_MAX_MOLECULES_COUNT); - STATIC_ASSERT(SLN_MAX_ISOTOPES_COUNT <= SHTR_MAX_ISOTOPES_COUNT, - Invalid_SLN_MAX_ISOTOPES_COUNT); - struct shtr_lines_view_create_args view_args = SHTR_LINES_VIEW_CREATE_ARGS_NULL; struct shtr_lines_view* view = NULL; size_t imol, iiso; @@ -244,6 +244,54 @@ error: } static void +molecules_params_reset(struct molecule_params params[SLN_MAX_MOLECULES_COUNT]) +{ + size_t imol; + ASSERT(params); + + /* Clean up the params */ + FOR_EACH(imol, 0, SLN_MAX_MOLECULES_COUNT) { + size_t iiso; + params[imol].concentration = -1; + params[imol].cutoff = -1; + FOR_EACH(iiso, 0, SLN_MAX_ISOTOPES_COUNT) { + params[imol].isotopes_abundance[iiso] = -1; + } + } +} + +static res_T +setup_molecule_params + (struct sln_device* sln, + const struct sln_tree_create_args* args, + struct molecule_params params[SLN_MAX_MOLECULES_COUNT]) +{ + size_t imol; + ASSERT(sln && args && params); + (void)sln; + + molecules_params_reset(params); + + FOR_EACH(imol, 0, args->nmolecules) { + const struct sln_molecule* mol = &args->molecules[imol]; + size_t iiso; + ASSERT(mol->id < SLN_MAX_MOLECULES_COUNT); + + params[mol->id].concentration = mol->concentration; + params[mol->id].cutoff = mol->cutoff; + + FOR_EACH(iiso, 0, mol->nisotopes) { + const struct sln_isotope* iso = &mol->isotopes[iiso]; + ASSERT(iso->id_local < SLN_MAX_ISOTOPES_COUNT); + + params[mol->id].isotopes_abundance[iso->id_local] = iso->abundance; + } + } + + return RES_OK; +} + +static void release_tree(ref_T* ref) { struct sln_tree* tree = CONTAINER_OF(ref, struct sln_tree, ref); @@ -286,6 +334,8 @@ sln_tree_create res = create_lines_view(sln, args, &tree->lines_view); if(res != RES_OK) goto error; + res = setup_molecule_params(sln, args, tree->molecules_params); + if(res != RES_OK) goto error; res = tree_build(tree, args); if(res != RES_OK) goto error; diff --git a/src/sln_tree_c.h b/src/sln_tree_c.h @@ -40,7 +40,18 @@ static const struct sln_node SLN_NODE_NULL = SLN_NODE_NULL__; #define DARRAY_NAME node #include <rsys/dynamic_array.h> +struct molecule_params { + /* Map the isotope local identifier to its abundance */ + double isotopes_abundance[SLN_MAX_ISOTOPES_COUNT]; + + double concentration; + double cutoff; +}; + struct sln_tree { + /* Map the molecule id to its parameters (i.e. concentration, cutoff) */ + struct molecule_params molecules_params[SLN_MAX_MOLECULES_COUNT]; + struct shtr_lines_view* lines_view; /* Set of lines */ struct darray_node nodes; /* Nodes used to partition the lines */