Skip to content

Commit 031b44c

Browse files
authored
Merge pull request #2150 from tkittel/main
Fix NCrystal_sample 3D visualisation.
2 parents b24a1e0 + acb9885 commit 031b44c

File tree

1 file changed

+23
-31
lines changed

1 file changed

+23
-31
lines changed

mcstas-comps/samples/NCrystal_sample.comp

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/*****************************************************************************
22
*
3-
* This file is part of NCrystal (see https://mctools.github.io/ncrystal/)
4-
*
5-
* Copyright 2015-2022 NCrystal developers
3+
* This file used to be part of NCrystal (https://mctools.github.io/ncrystal/),
4+
* but since McStas 3.2 (2022) this component is maintained as part of McStas.
65
*
76
* Licensed under the Apache License, Version 2.0 (the "License");
87
* you may not use this file except in compliance with the License.
@@ -21,32 +20,31 @@
2120
*
2221
* %I
2322
* Written by: NCrystal developers
23+
* Date: 2017
2424
* Version: 1.0.0
2525
* Origin: NCrystal Developers (European Spallation Source ERIC and DTU Nutech)
2626
*
2727
* McStas sample component for the NCrystal library for thermal neutron transport
2828
* (<a href="https://github.com/mctools/ncrystal">www</a>).
2929
*
3030
* %D
31-
* McStas sample component for the NCrystal scattering library.
32-
* Find more information at <a href="https://github.com/mctools/ncrystal/wiki">the NCrystal wiki</a>.
33-
* In particular, browse the available datafiles at <a href="https://github.com/mctools/ncrystal/wiki/Data-library">Data-library</a>
34-
* and read about the format of the configuration string expected in
35-
* the "cfg" parameter at <a href="https://github.com/mctools/ncrystal/wiki/Using-NCrystal">Using-NCrystal</a>.
31+
* McStas sample component using the NCrystal library for thermal neutron
32+
* transport in a single bulk material filling a single simple convex volume
33+
* (box, sphere or cylinder).
34+
*
35+
* The geometrical layout of the volume is determined via the xwidth, yheight,
36+
* zdepth, and radius parameters, and the material being modelled is determined
37+
* via an NCrystal configuration string ("cfg-string").
3638
*
37-
* <p/>NCrystal is available under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0 license</a>.
38-
* Depending on the configuration choices, optional NCrystal
39-
* modules under different licenses might be enabled,
40-
* see <a href="https://github.com/mctools/ncrystal/blob/master/NOTICE">here</a> for more details.
39+
* For more information about NCrystal and cfg-strings, refer to the <a href="https://github.com/mctools/ncrystal/wiki">NCrystal wiki</a>.
40+
* In particular, browse the available datafiles at <a href="https://github.com/mctools/ncrystal/wiki/Data-library">Data-library</a> and read about the
41+
* format of the cfg-string expected in the "cfg" parameter at <a href="https://github.com/mctools/ncrystal/wiki/Using-NCrystal">Using-NCrystal</a>.
4142
*
42-
* Note also that for more complicated geometries, it might be desirable to use
43-
* NCrystal via the McStas Union components instead.
43+
* For more complicated geometries, it might be desirable to use NCrystal via the
44+
* McStas Union components instead.
4445
*
45-
* <p/>This NCrystal_sample component used to be shipped with NCrystal itself,
46-
* but starting with McStas 3.2 it is shipped along with McStas itself
47-
* (accordingly the components version number is reset to 1.0.0 to avoid
48-
* confusion). As engine it will use whichever NCrystal installation is
49-
* available and associated with the "ncrystal-config" command.
46+
* Note that the physics backend of this component will be whichever NCrystal
47+
* installation is available and associated with the "ncrystal-config" command.
5048
*
5149
* %P
5250
* Input parameters:
@@ -65,7 +63,7 @@
6563
*******************************************************************************/
6664

6765
DEFINE COMPONENT NCrystal_sample
68-
SETTING PARAMETERS (string cfg="void", absorptionmode=1, multscat=1, xwidth=0, yheight=0, zdepth=0, radius=0 )
66+
SETTING PARAMETERS (string cfg="void", xwidth=0, yheight=0, zdepth=0, radius=0, absorptionmode=1, multscat=1 )
6967
DEPENDENCY "@NCRYSTALFLAGS@"
7068
NOACC /* Notice: you must remove this line if using the legacy McStas 2.x branch. */
7169

@@ -370,24 +368,18 @@ FINALLY
370368

371369
MCDISPLAY
372370
%{
373-
//NB: Future McStas (2.5?) is slated to introduce mcdis_cylinder and
374-
//mcdis_sphere functions, which we at that point should likely use.
375371
switch (geoparams.shape) {
376372
case NC_CYLINDER:
377-
mcdis_circle("xz", 0, geoparams.dy/2.0, 0, geoparams.rradius);
378-
mcdis_circle("xz", 0, -geoparams.dy/2.0, 0, geoparams.rradius);
379-
mcdis_line(-geoparams.rradius, -geoparams.dy/2.0, 0, -geoparams.rradius, +geoparams.dy/2.0, 0);
380-
mcdis_line(+geoparams.rradius, -geoparams.dy/2.0, 0, +geoparams.rradius, +geoparams.dy/2.0, 0);
381-
mcdis_line(0, -geoparams.dy/2.0, -geoparams.rradius, 0, +geoparams.dy/2.0, -geoparams.rradius);
382-
mcdis_line(0, -geoparams.dy/2.0, +geoparams.rradius, 0, +geoparams.dy/2.0, +geoparams.rradius);
373+
mcdis_cylinder( 0., 0., 0.,
374+
geoparams.rradius,
375+
geoparams.dy,
376+
0 , 0.0 , 1.0 , 0.0);
383377
break;
384378
case NC_BOX:
385379
mcdis_box(0., 0., 0., geoparams.dx, geoparams.dy, geoparams.dz,0, 0, 1, 0);
386380
break;
387381
case NC_SPHERE:
388-
mcdis_circle("xy", 0., 0., 0., geoparams.rradius);
389-
mcdis_circle("xz", 0., 0., 0., geoparams.rradius);
390-
mcdis_circle("yz", 0., 0., 0., geoparams.rradius);
382+
mcdis_sphere(0.0,0.0,0.0,geoparams.rradius);
391383
break;
392384
};
393385
%}

0 commit comments

Comments
 (0)