/******************************************************************************* * * McStas, the neutron ray-tracing Monte-Carlo software. * Copyright(C) 1999,2000 Risoe National Laboratory. * * %I * Written by: Kristian Nielsen * Date: 1999 * Version: $Revision: 1.1.1.1 $ * Origin: McStas release * * Optimization specifier for the Source_adapt component. * * %D * This components works together with the Source_adapt component, and * is used to define the criteria for selecting which neutrons are * considered "good" in the adaptive algorithm. The name of the * associated Source_adapt component in the instrument definition is * given as parameter. The component is special in that its position * does not matter; all neutrons that have not been absorbed prior to * the component are considered "good". * * %P * INPUT PARAMETERS: * * source_comp: The name of the Source_adapt component in the * instrument definition. * * %E *******************************************************************************/ DEFINE COMPONENT Adapt_check DEFINITION PARAMETERS (source_comp) SETTING PARAMETERS () STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p) TRACE %{ double new_v, psi; struct source_adapt *adpt = &(MC_GETPAR(source_comp, adpt)); if(p == 0) ABSORB; psi = p/adpt->pi; adpt->psi[adpt->idx] += psi; adpt->psi_tot += psi/adpt->n[adpt->idx]; new_v = (1 - adpt->a_beta)*adpt->factor*adpt->psi[adpt->idx]/ (adpt->n[adpt->idx]*adpt->psi_tot) + adpt->a_beta/adpt->num; adapt_tree_add(adpt->atree, adpt->idx, new_v - adpt->atree->v[adpt->idx]); %} MCDISPLAY %{ magnify(""); %} END