| 1 | #cxx . . $ `<file>/ncrystal_core/include/NCrystal/NCMatCfg.hh`/ifndef NCrystal_MatCfg_hh |
| 2 | #define NCrystal_MatCfg_hhcxx . . $ `ncrystal_core/include/NCrystal/NCMatCfg.hh:2:9`! |
| 3 | |
| 4 | //////////////////////////////////////////////////////////////////////////////// |
| 5 | // // |
| 6 | // This file is part of NCrystal (see https://mctools.github.io/ncrystal/) // |
| 7 | // // |
| 8 | // Copyright 2015-2022 NCrystal developers // |
| 9 | // // |
| 10 | // Licensed under the Apache License, Version 2.0 (the "License"); // |
| 11 | // you may not use this file except in compliance with the License. // |
| 12 | // You may obtain a copy of the License at // |
| 13 | // // |
| 14 | // http://www.apache.org/licenses/LICENSE-2.0 // |
| 15 | // // |
| 16 | // Unless required by applicable law or agreed to in writing, software // |
| 17 | // distributed under the License is distributed on an "AS IS" BASIS, // |
| 18 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // |
| 19 | // See the License for the specific language governing permissions and // |
| 20 | // limitations under the License. // |
| 21 | // // |
| 22 | //////////////////////////////////////////////////////////////////////////////// |
| 23 | |
| 24 | #include "NCrystal/NCTypes.hh"cxx . . $ `<file>/ncrystal_core/include/NCrystal/NCTypes.hh`/ |
| 25 | #include "NCrystal/NCTextData.hh"cxx . . $ `<file>/ncrystal_core/include/NCrystal/NCTextData.hh`/ |
| 26 | |
| 27 | namespace NCrystalcxx . . $ NCrystal/ { |
| 28 | |
| 29 | class SCOrientationcxx . . $ NCrystal/SCOrientation#; |
| 30 | class MatInfoCfgcxx . . $ NCrystal/MatInfoCfg#; |
| 31 | |
| 32 | class NCRYSTAL_APIcxx . . $ `ncrystal_core/include/NCrystal/ncapi.h:51:13`! MatCfgcxx . . $ NCrystal/MatCfg# { |
| 33 | public: |
| 34 | |
| 35 | ////////////////////////////////////////////////////////////////////////////// |
| 36 | // // |
| 37 | // Class which is used to encapsulate the high-level configuration of a // |
| 38 | // given material. // |
| 39 | // // |
| 40 | // The configuration can either be set up and edited via the API below, or // |
| 41 | // simply by providing a so-called configuration string in the // |
| 42 | // constructor. Once a MatCfg object is set up, it is possible to use it // |
| 43 | // to load corresponding physics objects, by passing it to the global // |
| 44 | // createInfo, createScatter, or createAbsorption functions (cf. NCFact.hh).// |
| 45 | // // |
| 46 | // In the simplest case, the configuration will combine one source of input // |
| 47 | // (text) data (for instance an NCMAT file) with a set of configuration // |
| 48 | // parameters (for instance the material temperature or a single crystal // |
| 49 | // orientation). In more advanced cases, it is also possible for a MatCfg // |
| 50 | // object to define a multi-phase material. Such a MatCfg object does not // |
| 51 | // contain input data or (with a few exceptions) configuration parameters, // |
| 52 | // but instead simply provides a list of child MatCfg objects, one for each // |
| 53 | // phase. // |
| 54 | // // |
| 55 | // NB: Even if the MatCfg object is not "multi-phase", and only refers to // |
| 56 | // a single source of input data, the physics objects loaded with it might // |
| 57 | // still represent a multi-phase material. This follows from the fact that // |
| 58 | // for instance a single NCMAT file can provide a multi-phase material, but // |
| 59 | // the MatCfg object itself can not know whether or not this is the case. // |
| 60 | // // |
| 61 | ////////////////////////////////////////////////////////////////////////////// |
| 62 | |
| 63 | ///////////////////////////////////////////////////////////////////////////// |
| 64 | // Cfg-string constructor: // |
| 65 | ///////////////////////////////////////////////////////////////////////////// |
| 66 | // |
| 67 | |
| 68 | MatCfgcxx . . $ NCrystal/MatCfg#MatCfg(9c546c94e5fcce4e).( const stdcxx . . $ std/::stringcxx . . $ std/string#& datafile_and_parameters ); |
| 69 | MatCfgcxx . . $ NCrystal/MatCfg#MatCfg(85c52e162fed56f9).( const char* datafile_and_parameters ); |
| 70 | |
| 71 | // Construct material configuration by providing a configuration |
| 72 | // string. Such a cfg-string must at least contain the name identifying a |
| 73 | // piece of input data (in any supported format). This can for instance be a |
| 74 | // filename, and more generally it must be anything which can be used look |
| 75 | // up a TextData object via the infrastructure in NCFactImpl.hh, after |
| 76 | // constructing a TextDataPath object with it (see also NCDataSources.hh for |
| 77 | // how to modify this search). |
| 78 | // |
| 79 | // Additionally, it is optionally possible to set configuration parameters |
| 80 | // by appending one or more occurances of "<name>=<value>" to the file name, |
| 81 | // all separated with semi-colons (;). Alternatively, the parameters can |
| 82 | // also be set via specific set_xxx() methods below. |
| 83 | // |
| 84 | // Thus the single line: |
| 85 | // |
| 86 | // MatCfg cfg("myfile.ncmat;temp=77.0;density=2.3gcm3"); |
| 87 | // |
| 88 | // Has the same effect as the three lines: |
| 89 | // |
| 90 | // MatCfg cfg("myfile.ncmat"); |
| 91 | // cfg.set_temp( Temperature{77.0} ); |
| 92 | // cfg.set_density( Density{2.3} ); |
| 93 | // |
| 94 | // See notes below concerning multiphase materials, in-file embedding of |
| 95 | // parameters, data caching, and instantiation directly from text data. |
| 96 | // |
| 97 | // The supported parameter names are (for the latest NCrystal release) |
| 98 | // documented at: |
| 99 | // |
| 100 | // https://github.com/mctools/ncrystal/wiki/CfgRefDoc |
| 101 | // |
| 102 | // In case your version of NCrystal differs from the one mentioned on the |
| 103 | // wiki page above, you can instead generate the same documentation by |
| 104 | // invoking one of the following: |
| 105 | // |
| 106 | // ncrystal_inspectfile --doc #From the command line |
| 107 | // NCrystal::MatCfg::genDoc(std::cout); //#From C++ code. |
| 108 | // print( NCrystal.generateCfgStrDoc() ) #From Python code |
| 109 | // |
| 110 | // C++ savvy users might also wish to take a look at the internal header |
| 111 | // file, NCCfgVars.hh, where the various parameters are actually defined. |
| 112 | // |
| 113 | // Multiphase materials can be composed directly in cfg-strings by simple |
| 114 | // additive composition from existing materials, as will be explained in the |
| 115 | // following. Note that very complicated multiphase materials, or those with |
| 116 | // nanostructures resulting in SANS physics, might be better described in |
| 117 | // NCMAT data. In that case, resulting physics objects might be multiphased, |
| 118 | // although the MatCfg object will seem to be single phase. |
| 119 | // |
| 120 | // The configuration string syntax used to define a multiphase material with |
| 121 | // N phases is: |
| 122 | // |
| 123 | // "phases<FRAC1*CFG1&..&FRACN*CFGN>[;COMMONCFG]" |
| 124 | // |
| 125 | // Here FRACi is the (by-volume) fraction of the i'th component, and |
| 126 | // COMMONCFG, CFG1, ..., CFGN are cfg strings. The final cfg string of the |
| 127 | // i'th component is "CFG1;COMMONCFG", so COMMONCFG will be the most |
| 128 | // convenient place to change parameters which should affect all phases, |
| 129 | // such as material temperature. One special exception is the use of |
| 130 | // "phasechoice" and "density" parameters (see below) in the COMMONCFG |
| 131 | // string, which will always be applied only to the top-level MatCfg object, |
| 132 | // and not be passed on to the child phases (doing so would defeat the |
| 133 | // purpose of using phasechoice parameters). |
| 134 | // |
| 135 | // Examples: |
| 136 | // |
| 137 | // * Equal (by volume) mix of Al and Mg powder: |
| 138 | // "phases<0.5*Al_sg225.ncmat&0.5*Mg_sg194.ncmat>" |
| 139 | // * Same at T=20K: |
| 140 | // "phases<0.5*Al_sg225.ncmat&0.5*Mg_sg194.ncmat>;temp=20K" |
| 141 | // * Aluminium with voids: |
| 142 | // "phases < 0.99 * Al_sg225.ncmat & 0.01 * void.ncmat >" |
| 143 | // * Alumina powder suspended in water: |
| 144 | // "phases<0.01*Al2O3_sg167_Corundum.ncmat&0.99*LiquidWaterH2O_T293.6K.ncmat>" |
| 145 | // |
| 146 | // Also note that in case where a material is defined using the "phases<..>" |
| 147 | // multiphase syntax, but only one phase is actually specified - the |
| 148 | // resulting MatCfg object will end up as a regular single phase object. |
| 149 | // |
| 150 | // A multi-phase MatCfg object is primarily useful since it can be passed to |
| 151 | // createInfo, createAbsorption, or createScatter as any MatCfg object and |
| 152 | // receive Info, Absorption, or Scatter physics objects in return. But note |
| 153 | // that some methods on multi-phase MatCfg objects are unavailable |
| 154 | // (i.e. will throw exceptions). This can for instance happen when asking |
| 155 | // for the value of a parameter which is not the same in all phases. Setting |
| 156 | // parameters is on the other hand always possible, and merely leads to the |
| 157 | // value being set for all phases (with the exception of phasechoice/density |
| 158 | // parameters as noted above). Additionally, a multi-phase MatCfg object |
| 159 | // never has text data directly available, since such data is associated |
| 160 | // with the individual phases. |
| 161 | // |
| 162 | // In addition to the cfg-string syntax above, it is also possible to setup |
| 163 | // multi-phase configurations with the following constructors: |
| 164 | |
| 165 | using Phasecxx . . $ NCrystal/MatCfg#Phase# = stdcxx . . $ std/::pair<double,MatCfgcxx . . $ NCrystal/MatCfg#>; |
| 166 | using PhaseListcxx . . $ NCrystal/MatCfg#PhaseList# = stdcxx . . $ std/::vectorcxx . . $ std/vector#<Phasecxx . . $ NCrystal/MatCfg#Phase#>; |
| 167 | MatCfgcxx . . $ NCrystal/MatCfg#MatCfg(5db59a7e5704bac9).( PhaseListcxx . . $ NCrystal/MatCfg#PhaseList#&& ); |
| 168 | MatCfgcxx . . $ NCrystal/MatCfg#MatCfg(d7a8cf0f28a57228).( const PhaseListcxx . . $ NCrystal/MatCfg#PhaseList#& ); |
| 169 | |
| 170 | //////////////////////////////////////////////////////////////////////////// |
| 171 | // For additional flexiblity, it is also possible to instantiate MatCfg |
| 172 | // objects by providing the bulk text data directly instead of a filename - |
| 173 | // in the form of either a TextData object or a string with the content. In |
| 174 | // either case, there should be enough information available that the |
| 175 | // framework can figure out the type of data provided. In order of |
| 176 | // preference, this will be done by looking at #1 the explicit dataType |
| 177 | // string provided as a parameter to the constructor (if non-empty), #2 the |
| 178 | // dataType from the TextData object, #3 if the TextData content starts with |
| 179 | // the 5 characters "NCMAT", the type will be inferred to be "ncmat", and |
| 180 | // finally as a last resort, #4 the file extension of the filename provided, |
| 181 | // if any. If all these options fail to determine the data format, a |
| 182 | // BadInput exception will be thrown. |
| 183 | // |
| 184 | // Note that providing data manually as a string will result in a new |
| 185 | // TextData object being constructed internally with a new dataUID(), with |
| 186 | // implications for downstream-caching. |
| 187 | |
| 188 | explicit MatCfgcxx . . $ NCrystal/MatCfg#MatCfg(9f5e31dad82a4622).( TextDataSPcxx . . $ NCrystal/TextDataSP#, stdcxx . . $ std/::stringcxx . . $ std/string# parameters =cxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391). {} ); |
| 189 | |
| 190 | //To avoid overload ambiguities, the constructor accepting raw data directly |
| 191 | //is encapsulated in a static creation method: |
| 192 | static MatCfgcxx . . $ NCrystal/MatCfg# createFromRawDatacxx . . $ NCrystal/MatCfg#createFromRawData(12d7de10410b6039).( stdcxx . . $ std/::stringcxx . . $ std/string#&& data, |
| 193 | stdcxx . . $ std/::stringcxx . . $ std/string# parameters =cxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391). {}, |
| 194 | stdcxx . . $ std/::stringcxx . . $ std/string# dataType =cxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391). {} ); |
| 195 | |
| 196 | //Generate cfg-string documentation, either full output including |
| 197 | //explanations, short output with one variable per line, or as a JSON data |
| 198 | //structure: |
| 199 | enum class GenDocModecxx . . $ NCrystal/MatCfg#GenDocMode# { TXT_SHORTcxx . . $ NCrystal/MatCfg#GenDocMode#TXT_SHORT., TXT_FULLcxx . . $ NCrystal/MatCfg#GenDocMode#TXT_FULL., JSONcxx . . $ NCrystal/MatCfg#GenDocMode#JSON. }; |
| 200 | static void genDoccxx . . $ NCrystal/MatCfg#genDoc(9a077dc7fe455428).( stdcxx . . $ std/::ostreamcxx . . $ std/ostream#&, GenDocModecxx . . $ NCrystal/MatCfg#GenDocMode# = GenDocModecxx . . $ NCrystal/MatCfg#GenDocMode#::TXT_FULLcxx . . $ NCrystal/MatCfg#GenDocMode#TXT_FULL. ); |
| 201 | |
| 202 | ///////////////////////////////////////////////////////////////////////////// |
| 203 | // Methods for setting parameters: // |
| 204 | ///////////////////////////////////////////////////////////////////////////// |
| 205 | // |
| 206 | // Directly set from C++ code: |
| 207 | void set_tempcxx . . $ NCrystal/MatCfg#set_temp(38362fe14a1d1792).( Temperaturecxx . . $ NCrystal/Temperature# ); |
| 208 | void set_tempcxx . . $ NCrystal/MatCfg#set_temp(ba8836b59fb42830).( double ); |
| 209 | void set_dcutoffcxx . . $ NCrystal/MatCfg#set_dcutoff(ba8836b59fb42830).( double ); |
| 210 | void set_dcutoffupcxx . . $ NCrystal/MatCfg#set_dcutoffup(ba8836b59fb42830).( double ); |
| 211 | void set_moscxx . . $ NCrystal/MatCfg#set_mos(b58154f96094a387).( MosaicityFWHMcxx . . $ NCrystal/MosaicityFWHM# ); |
| 212 | void set_mospreccxx . . $ NCrystal/MatCfg#set_mosprec(ba8836b59fb42830).( double ); |
| 213 | void set_sccutoffcxx . . $ NCrystal/MatCfg#set_sccutoff(ba8836b59fb42830).( double ); |
| 214 | void set_dirtolcxx . . $ NCrystal/MatCfg#set_dirtol(ba8836b59fb42830).( double ); |
| 215 | void set_coh_elascxx . . $ NCrystal/MatCfg#set_coh_elas(b45ddcbc8423892c).( bool ); |
| 216 | void set_incoh_elascxx . . $ NCrystal/MatCfg#set_incoh_elas(b45ddcbc8423892c).( bool ); |
| 217 | void set_sanscxx . . $ NCrystal/MatCfg#set_sans(b45ddcbc8423892c).( bool ); |
| 218 | void set_inelascxx . . $ NCrystal/MatCfg#set_inelas(9c546c94e5fcce4e).( const stdcxx . . $ std/::stringcxx . . $ std/string#& ); |
| 219 | void set_infofactorycxx . . $ NCrystal/MatCfg#set_infofactory(9c546c94e5fcce4e).( const stdcxx . . $ std/::stringcxx . . $ std/string#& ); |
| 220 | void set_scatfactorycxx . . $ NCrystal/MatCfg#set_scatfactory(9c546c94e5fcce4e).( const stdcxx . . $ std/::stringcxx . . $ std/string#& ); |
| 221 | void set_absnfactorycxx . . $ NCrystal/MatCfg#set_absnfactory(9c546c94e5fcce4e).( const stdcxx . . $ std/::stringcxx . . $ std/string#& ); |
| 222 | void set_lcmodecxx . . $ NCrystal/MatCfg#set_lcmode(d4f767463ce0a6b3).( stdcxx . . $ std/::int_least32_tcxx . . $ std/int_least32_t# ); |
| 223 | void set_ucnmodecxx . . $ NCrystal/MatCfg#set_ucnmode(128a013dd2c81592).( const Optionalcxx . . $ NCrystal/Optional#<UCNModecxx . . $ NCrystal/UCNMode#>& ); |
| 224 | void set_vdosluxcxx . . $ NCrystal/MatCfg#set_vdoslux(d4f767463ce0a6b3).( int ); |
| 225 | void set_atomdbcxx . . $ NCrystal/MatCfg#set_atomdb(9c546c94e5fcce4e).( const stdcxx . . $ std/::stringcxx . . $ std/string#& ); |
| 226 | void set_lcaxiscxx . . $ NCrystal/MatCfg#set_lcaxis(c7a3af544755f98a).( const LCAxiscxx . . $ NCrystal/LCAxis#& ); |
| 227 | void set_dir1cxx . . $ NCrystal/MatCfg#set_dir1(676d2a787402154e).( const HKLPointcxx . . $ NCrystal/HKLPoint#&, const LabAxiscxx . . $ NCrystal/LabAxis#& ); |
| 228 | void set_dir1cxx . . $ NCrystal/MatCfg#set_dir1(a8749f20c8b13ace).( const CrystalAxiscxx . . $ NCrystal/CrystalAxis#&, const LabAxiscxx . . $ NCrystal/LabAxis#& ); |
| 229 | void set_dir2cxx . . $ NCrystal/MatCfg#set_dir2(676d2a787402154e).( const HKLPointcxx . . $ NCrystal/HKLPoint#&, const LabAxiscxx . . $ NCrystal/LabAxis#& ); |
| 230 | void set_dir2cxx . . $ NCrystal/MatCfg#set_dir2(a8749f20c8b13ace).( const CrystalAxiscxx . . $ NCrystal/CrystalAxis#&, const LabAxiscxx . . $ NCrystal/LabAxis#& ); |
| 231 | void set_dir1cxx . . $ NCrystal/MatCfg#set_dir1(b3539921af25e63c).( const OrientDircxx . . $ NCrystal/OrientDir#& ); |
| 232 | void set_dir2cxx . . $ NCrystal/MatCfg#set_dir2(b3539921af25e63c).( const OrientDircxx . . $ NCrystal/OrientDir#& ); |
| 233 | void setOrientationcxx . . $ NCrystal/MatCfg#setOrientation(ba17e411db8031d1).( const SCOrientationcxx . . $ NCrystal/SCOrientation#& );//sets dir1+dir2+dirtol |
| 234 | |
| 235 | /////////////////////////////////////////////////////////////////////////////////// |
| 236 | //As explained above, MatCfg objects optionally retain a "density state", |
| 237 | //which can be either a scaling of, or an absolute override of, the density |
| 238 | //that will otherwise be created from the configuration. Note that final |
| 239 | //density value must be obtained from the loaded Info objects, not the |
| 240 | //MatCfg objects which can't know the underlying material density which it |
| 241 | //is possibly scaling. |
| 242 | |
| 243 | void set_densitycxx . . $ NCrystal/MatCfg#set_density(6eb21a15c5702c7a).( const Densitycxx . . $ NCrystal/Density#& ); |
| 244 | void set_densitycxx . . $ NCrystal/MatCfg#set_density(8dff33dcdd59bb45).( const NumberDensitycxx . . $ NCrystal/NumberDensity#& ); |
| 245 | void scale_densitycxx . . $ NCrystal/MatCfg#scale_density(ba8836b59fb42830).( double );//scales existing state (NB: repeated calls have commulative effect!) |
| 246 | void set_densitycxx . . $ NCrystal/MatCfg#set_density(cf59eba3bb5081c6).( const DensityStatecxx . . $ NCrystal/DensityState#& );// (NB: repeated calls have commulative effect if argument is scale factor!) |
| 247 | DensityStatecxx . . $ NCrystal/DensityState# get_densitycxx . . $ NCrystal/MatCfg#get_density(e785fa1350b5c255).() const; |
| 248 | bool hasDensityOverridecxx . . $ NCrystal/MatCfg#hasDensityOverride(50ce9a9e25b4a850).() const;//True if get_density() does not yield {SCALEFACTOR,1.0}. |
| 249 | |
| 250 | // |
| 251 | // Set parameters from a string, using the same format as that supported by |
| 252 | // the constructor, e.g. "par1=val1;...;parn=valn": |
| 253 | void applyStrCfgcxx . . $ NCrystal/MatCfg#applyStrCfg(9c546c94e5fcce4e).( const stdcxx . . $ std/::stringcxx . . $ std/string#& ); |
| 254 | |
| 255 | ///////////////////////////////////////////////////////////////////////////// |
| 256 | // Methods for accessing parameters or derived information: // |
| 257 | ///////////////////////////////////////////////////////////////////////////// |
| 258 | // |
| 259 | // Directly access from C++ (might error for multiphase cfgs in case of |
| 260 | // inconsistent values across phases): |
| 261 | |
| 262 | Temperaturecxx . . $ NCrystal/Temperature# get_tempcxx . . $ NCrystal/MatCfg#get_temp(36406a9e08e0f484).() const; |
| 263 | double get_dcutoffcxx . . $ NCrystal/MatCfg#get_dcutoff(21b6c25e127938e2).() const; |
| 264 | double get_dcutoffupcxx . . $ NCrystal/MatCfg#get_dcutoffup(21b6c25e127938e2).() const; |
| 265 | MosaicityFWHMcxx . . $ NCrystal/MosaicityFWHM# get_moscxx . . $ NCrystal/MatCfg#get_mos(d3e4e6bb3ef0bd39).() const; |
| 266 | double get_mospreccxx . . $ NCrystal/MatCfg#get_mosprec(21b6c25e127938e2).() const; |
| 267 | double get_sccutoffcxx . . $ NCrystal/MatCfg#get_sccutoff(21b6c25e127938e2).() const; |
| 268 | double get_dirtolcxx . . $ NCrystal/MatCfg#get_dirtol(21b6c25e127938e2).() const; |
| 269 | const LCAxiscxx . . $ NCrystal/LCAxis#& get_lcaxiscxx . . $ NCrystal/MatCfg#get_lcaxis(5ee5a0d3eefe6ff).() const; |
| 270 | stdcxx . . $ std/::stringcxx . . $ std/string# get_infofactorycxx . . $ NCrystal/MatCfg#get_infofactory(219584694fe2b248).() const; |
| 271 | stdcxx . . $ std/::stringcxx . . $ std/string# get_scatfactorycxx . . $ NCrystal/MatCfg#get_scatfactory(219584694fe2b248).() const; |
| 272 | stdcxx . . $ std/::stringcxx . . $ std/string# get_absnfactorycxx . . $ NCrystal/MatCfg#get_absnfactory(219584694fe2b248).() const; |
| 273 | stdcxx . . $ std/::int_least32_tcxx . . $ std/int_least32_t# get_lcmodecxx . . $ NCrystal/MatCfg#get_lcmode(455f465bc33b4cdf).() const; |
| 274 | StrViewcxx . . $ NCrystal/StrView# get_ucnmode_strcxx . . $ NCrystal/MatCfg#get_ucnmode_str(a6249fb379d5baea).() const; |
| 275 | Optionalcxx . . $ NCrystal/Optional#<UCNModecxx . . $ NCrystal/UCNMode#> get_ucnmodecxx . . $ NCrystal/MatCfg#get_ucnmode(f1d2d0594cdb893d).() const; |
| 276 | int get_vdosluxcxx . . $ NCrystal/MatCfg#get_vdoslux(455f465bc33b4cdf).() const; |
| 277 | stdcxx . . $ std/::stringcxx . . $ std/string# get_atomdbcxx . . $ NCrystal/MatCfg#get_atomdb(219584694fe2b248).() const; |
| 278 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<VectScxx . . $ NCrystal/VectS#> get_atomdb_parsedcxx . . $ NCrystal/MatCfg#get_atomdb_parsed(2dae8b5e0e18efde).() const; |
| 279 | bool get_coh_elascxx . . $ NCrystal/MatCfg#get_coh_elas(50ce9a9e25b4a850).() const; |
| 280 | bool get_incoh_elascxx . . $ NCrystal/MatCfg#get_incoh_elas(50ce9a9e25b4a850).() const; |
| 281 | bool get_sanscxx . . $ NCrystal/MatCfg#get_sans(50ce9a9e25b4a850).() const; |
| 282 | stdcxx . . $ std/::stringcxx . . $ std/string# get_inelascxx . . $ NCrystal/MatCfg#get_inelas(219584694fe2b248).() const; |
| 283 | OrientDircxx . . $ NCrystal/OrientDir# get_dir1cxx . . $ NCrystal/MatCfg#get_dir1(35094c398661bd5a).() const; |
| 284 | OrientDircxx . . $ NCrystal/OrientDir# get_dir2cxx . . $ NCrystal/MatCfg#get_dir2(35094c398661bd5a).() const; |
| 285 | |
| 286 | // Check if single/layered-single crystal, or access dir1+dir2+dirtol as |
| 287 | // SCOrientation (do not call any of these for multiphase cfgs): |
| 288 | bool isSingleCrystalcxx . . $ NCrystal/MatCfg#isSingleCrystal(50ce9a9e25b4a850).() const;//true if mos or orientation parameters are set |
| 289 | bool isLayeredCrystalcxx . . $ NCrystal/MatCfg#isLayeredCrystal(50ce9a9e25b4a850).() const;//true if lcaxis parameter is set |
| 290 | SCOrientationcxx . . $ NCrystal/SCOrientation# createSCOrientationcxx . . $ NCrystal/MatCfg#createSCOrientation(a516396603255d0f).() const; |
| 291 | |
| 292 | //Serialise in various forms. Note that if the MatCfg object was constructed |
| 293 | //from anonymous text data and not named data (filename), the data returned |
| 294 | //can not necessarily be used for an exact recreation of an equivalent |
| 295 | //MatCfg object. |
| 296 | //Note that for multiphase MatCfg objects, it is not allowed to call |
| 297 | //toEmbeddableCfg() or toStrCfg(include_datafile=false). |
| 298 | stdcxx . . $ std/::stringcxx . . $ std/string# toStrCfgcxx . . $ NCrystal/MatCfg#toStrCfg(66f8cb911a5426e1).( bool include_datafile = true ) const; |
| 299 | stdcxx . . $ std/::stringcxx . . $ std/string# toEmbeddableCfgcxx . . $ NCrystal/MatCfg#toEmbeddableCfg(219584694fe2b248).() const;//Produces a string like "NCRYSTALMATCFG[temp=500.0;dcutoff=0.2]" |
| 300 | //which can be embedded in data files. |
| 301 | stdcxx . . $ std/::stringcxx . . $ std/string# toJSONCfgcxx . . $ NCrystal/MatCfg#toJSONCfg(219584694fe2b248).() const;//same info as toStrCfg but as JSON struct. |
| 302 | void dumpcxx . . $ NCrystal/MatCfg#dump(25a4e5f405a65361).( stdcxx . . $ std/::ostreamcxx . . $ std/ostream# &out, bool add_endl=true ) const; |
| 303 | |
| 304 | ///////////////////////////////////////////////////////////////////////////// |
| 305 | // Associated text data (content and meta data of data file). // |
| 306 | ///////////////////////////////////////////////////////////////////////////// |
| 307 | // |
| 308 | // For non-multiphase cfg objects, access associated text and meta data: |
| 309 | const TextDatacxx . . $ NCrystal/TextData#& textDatacxx . . $ NCrystal/MatCfg#textData(8227591982158e5e).() const; |
| 310 | TextDataSPcxx . . $ NCrystal/TextDataSP# textDataSPcxx . . $ NCrystal/MatCfg#textDataSP(bd897887740b336b).() const; |
| 311 | const TextDataUIDcxx . . $ NCrystal/TextDataUID# textDataUIDcxx . . $ NCrystal/MatCfg#textDataUID(c1616c8e69d90f48).() const; |
| 312 | |
| 313 | //For non-multiphase cfg objects, access data type of text data (usually the |
| 314 | //extension of the data file). Calling this method should be the only manner |
| 315 | //of determining the format of the associated textData. |
| 316 | const stdcxx . . $ std/::stringcxx . . $ std/string#& getDataTypecxx . . $ NCrystal/MatCfg#getDataType(f4fff0029955a25f).() const; |
| 317 | |
| 318 | //For non-multiphase cfg objects, access data source name (for output only, |
| 319 | //code should not parse this!): |
| 320 | const DataSourceNamecxx . . $ NCrystal/DataSourceName#& getDataSourceNamecxx . . $ NCrystal/MatCfg#getDataSourceName(7c282b027f3443e1).() const; |
| 321 | |
| 322 | ///////////////////////////////////////////////////////////////////////////// |
| 323 | // Methods for multi-phase configurations: // |
| 324 | ///////////////////////////////////////////////////////////////////////////// |
| 325 | // |
| 326 | bool isSinglePhasecxx . . $ NCrystal/MatCfg#isSinglePhase(50ce9a9e25b4a850).() const; |
| 327 | bool isMultiPhasecxx . . $ NCrystal/MatCfg#isMultiPhase(50ce9a9e25b4a850).() const; |
| 328 | const PhaseListcxx . . $ NCrystal/MatCfg#PhaseList#& phasescxx . . $ NCrystal/MatCfg#phases(c8ff776003d07afd).() const;//empty list if isSinglePhase. |
| 329 | |
| 330 | |
| 331 | ///////////////////////////////////////////////////////////////////////////// |
| 332 | // Phasechoices // |
| 333 | ///////////////////////////////////////////////////////////////////////////// |
| 334 | |
| 335 | //Pick out child phases by index in Info::getPhases() list. Adding phase |
| 336 | //choices here (or with the "phasechoice" pseudo-parameter) can be used to |
| 337 | //ensure that passing the MatCfg object to high-level createXXX functions |
| 338 | //will result in the physics object corresponding to the given phase will be |
| 339 | //returned rather than the top-level objects (NOTE: this parameter picks out |
| 340 | //children at the Info object level, not at the MatCfg-level child |
| 341 | //phases). As child phase Info objects might themselves be multiphase, the |
| 342 | //method can be called more than once to navigate further into the Info |
| 343 | //object tree of child phases: |
| 344 | using PhaseChoicescxx . . $ NCrystal/MatCfg#PhaseChoices# = SmallVectorcxx . . $ NCrystal/SmallVector#<unsigned,4,SVModecxx . . $ NCrystal/SVMode#::LOWFOOTPRINT_IMPLICITCOPYcxx . . $ NCrystal/SVMode#LOWFOOTPRINT_IMPLICITCOPY.>; |
| 345 | const PhaseChoicescxx . . $ NCrystal/MatCfg#PhaseChoices#& getPhaseChoicescxx . . $ NCrystal/MatCfg#getPhaseChoices(db52a8d74838806a).() const; |
| 346 | void appendPhaseChoicescxx . . $ NCrystal/MatCfg#appendPhaseChoices(8e3b715dc649f8fe).( const PhaseChoicescxx . . $ NCrystal/MatCfg#PhaseChoices#& ); |
| 347 | void appendPhaseChoicecxx . . $ NCrystal/MatCfg#appendPhaseChoice(cb2f890c2fdad230).( unsigned ); |
| 348 | |
| 349 | ///////////////////////////////////////////////////////////////////////////// |
| 350 | // Copy/assign/move/clone/destruct // |
| 351 | ///////////////////////////////////////////////////////////////////////////// |
| 352 | // |
| 353 | // Copy/assignment/cloning is allowed and is a priori cheap, since internal |
| 354 | // data structures are shared until modified (aka copy-on-write): |
| 355 | // |
| 356 | MatCfgcxx . . $ NCrystal/MatCfg#MatCfg(11432a59958c3e2f).(const MatCfgcxx . . $ NCrystal/MatCfg#&); |
| 357 | MatCfgcxx . . $ NCrystal/MatCfg#& operatorcxx . . $ NCrystal/MatCfg#`operator=`(fad3d14ffdb2062b).=(const MatCfgcxx . . $ NCrystal/MatCfg#&); |
| 358 | MatCfgcxx . . $ NCrystal/MatCfg#MatCfg(27d9459d7701316e).( MatCfgcxx . . $ NCrystal/MatCfg#&& ); |
| 359 | MatCfgcxx . . $ NCrystal/MatCfg#& operatorcxx . . $ NCrystal/MatCfg#`operator=`(d48d9d805537a4ef).=(MatCfgcxx . . $ NCrystal/MatCfg#&&); |
| 360 | ~cxx . . $ NCrystal/MatCfg#`~MatCfg`(ced63f7c635d850d).MatCfgcxx . . $ NCrystal/MatCfg#(); |
| 361 | MatCfgcxx . . $ NCrystal/MatCfg# clonecxx . . $ NCrystal/MatCfg#clone(a74d05d60e987367).() const; |
| 362 | |
| 363 | ///////////////////////////////////////////////////////////////////////////// |
| 364 | // Interface for NCrystal factory infrastructure: // |
| 365 | ///////////////////////////////////////////////////////////////////////////// |
| 366 | |
| 367 | // Advanced interface, which is intended solely for use by the NCrystal |
| 368 | // factory infrastructure, for validation, factory selection, and to avoid |
| 369 | // unnecessary re-initialisation of expensive objects. |
| 370 | |
| 371 | //Create a "thinned" clone which does not keep a strong reference to the |
| 372 | //associated TextData object, but which still retains all other information |
| 373 | //(including the textDataUID) needed for comparisons, dumps, etc. Thus, such |
| 374 | //a clone is suitable for e.g. cache keys which must be kept around for |
| 375 | //comparison but which should not retain strong references to potentially |
| 376 | //large text data. |
| 377 | MatCfgcxx . . $ NCrystal/MatCfg# cloneThinnedcxx . . $ NCrystal/MatCfg#cloneThinned(a74d05d60e987367).() const; |
| 378 | bool isThinnedcxx . . $ NCrystal/MatCfg#isThinned(50ce9a9e25b4a850).() const; |
| 379 | |
| 380 | //Clone with phase choices or density discarded: |
| 381 | MatCfgcxx . . $ NCrystal/MatCfg# cloneWithoutPhaseChoicescxx . . $ NCrystal/MatCfg#cloneWithoutPhaseChoices(a74d05d60e987367).() const; |
| 382 | MatCfgcxx . . $ NCrystal/MatCfg# cloneWithoutDensityStatecxx . . $ NCrystal/MatCfg#cloneWithoutDensityState(a74d05d60e987367).() const; |
| 383 | |
| 384 | //Trivial means not multiphase, no phase choices, no density state override: |
| 385 | bool isTrivialcxx . . $ NCrystal/MatCfg#isTrivial(50ce9a9e25b4a850).() const; |
| 386 | |
| 387 | //Verify that the parameter values are not inconsistent or |
| 388 | //incomplete. Throws BadInput exception if they are. |
| 389 | void checkConsistencycxx . . $ NCrystal/MatCfg#checkConsistency(83f5f38750778ac8).() const; |
| 390 | |
| 391 | //Unspecified ordering (for usage as map keys): |
| 392 | bool operatorcxx . . $ NCrystal/MatCfg#`operator<`(a1fbdc894eeff5ab).<(const MatCfgcxx . . $ NCrystal/MatCfg#&) const; |
| 393 | |
| 394 | //Low-level access to parameter data: |
| 395 | const Cfgcxx . . $ NCrystal/Cfg/::CfgDatacxx . . $ NCrystal/Cfg/CfgData#& rawCfgDatacxx . . $ NCrystal/MatCfg#rawCfgData(cbb5a0ec4b12042d).() const;//NB: singlephase only fct |
| 396 | void applycxx . . $ NCrystal/MatCfg#apply(cddd3419e630eae5).( const Cfgcxx . . $ NCrystal/Cfg/::CfgDatacxx . . $ NCrystal/Cfg/CfgData#& );//NB: applies to all phases if multiphase |
| 397 | |
| 398 | ////////////////////////////////////////////////////////////////////// |
| 399 | // Obsolete functions kept temporarily for backwards compatibility. // |
| 400 | ////////////////////////////////////////////////////////////////////// |
| 401 | |
| 402 | //The get_packfact function was replaced with get_density which plays a |
| 403 | //slightly different role: |
| 404 | double get_packfactcxx . . $ NCrystal/MatCfg#get_packfact(21b6c25e127938e2).() const { return 1.0; } |
| 405 | //The ignorefilecfg keyword is no longer supported (it was too complicated |
| 406 | //to support): |
| 407 | bool ignoredEmbeddedConfigcxx . . $ NCrystal/MatCfg#ignoredEmbeddedConfig(50ce9a9e25b4a850).() const { return false; } |
| 408 | |
| 409 | private: |
| 410 | struct constructor_argscxx . . $ NCrystal/MatCfg#constructor_args#; |
| 411 | explicit MatCfgcxx . . $ NCrystal/MatCfg#MatCfg(69a2b543dc4385ea).( constructor_argscxx . . $ NCrystal/MatCfg#constructor_args#&& ); |
| 412 | struct from_raw_tcxx . . $ NCrystal/MatCfg#from_raw_t# {}; |
| 413 | explicit MatCfgcxx . . $ NCrystal/MatCfg#MatCfg(fb3f528b5d711935).( from_raw_tcxx . . $ NCrystal/MatCfg#from_raw_t#, stdcxx . . $ std/::stringcxx . . $ std/string#&& data, stdcxx . . $ std/::stringcxx . . $ std/string# pars, stdcxx . . $ std/::stringcxx . . $ std/string# ext ); |
| 414 | class Implcxx . . $ NCrystal/MatCfg#Impl#; |
| 415 | class Impl2cxx . . $ NCrystal/MatCfg#Impl2#; |
| 416 | COWPimplcxx . . $ NCrystal/COWPimpl#<Implcxx . . $ NCrystal/MatCfg#Impl#> m_implcxx . . $ NCrystal/MatCfg#m_impl.; |
| 417 | COWPimplcxx . . $ NCrystal/COWPimpl#<Impl2cxx . . $ NCrystal/MatCfg#Impl2#> m_impl2cxx . . $ NCrystal/MatCfg#m_impl2.; |
| 418 | OptionalTextDataSPcxx . . $ NCrystal/OptionalTextDataSP# m_textDataSPcxx . . $ NCrystal/MatCfg#m_textDataSP.; |
| 419 | friend class MatInfoCfgcxx . . $ NCrystal/MatInfoCfg#; |
| 420 | }; |
| 421 | |
| 422 | NCRYSTAL_APIcxx . . $ `ncrystal_core/include/NCrystal/ncapi.h:51:13`! stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& operatorcxx . . $ NCrystal/`operator<<`(698ba43f8163e7b3).<< (stdcxx . . $ std/::ostreamcxx . . $ std/ostream#&, const MatCfgcxx . . $ NCrystal/MatCfg#&); |
| 423 | |
| 424 | } |
| 425 | |
| 426 | |
| 427 | //////////////////////////// |
| 428 | // Inline implementations // |
| 429 | //////////////////////////// |
| 430 | |
| 431 | namespace NCrystalcxx . . $ NCrystal/ { |
| 432 | inline void MatCfgcxx . . $ NCrystal/MatCfg#::set_tempcxx . . $ NCrystal/MatCfg#set_temp(ba8836b59fb42830).( double t ) { set_tempcxx . . $ NCrystal/MatCfg#set_temp(38362fe14a1d1792).(Temperaturecxx . . $ NCrystal/Temperature#{t}); } |
| 433 | inline MatCfgcxx . . $ NCrystal/MatCfg# MatCfgcxx . . $ NCrystal/MatCfg#::clonecxx . . $ NCrystal/MatCfg#clone(a74d05d60e987367).() const { return MatCfgcxx . . $ NCrystal/MatCfg#(*this); } |
| 434 | inline const TextDatacxx . . $ NCrystal/TextData#& MatCfgcxx . . $ NCrystal/MatCfg#::textDatacxx . . $ NCrystal/MatCfg#textData(8227591982158e5e).() const { return textDataSPcxx . . $ NCrystal/MatCfg#textDataSP(bd897887740b336b).(); } |
| 435 | inline void MatCfgcxx . . $ NCrystal/MatCfg#::scale_densitycxx . . $ NCrystal/MatCfg#scale_density(ba8836b59fb42830).( double val ) |
| 436 | { |
| 437 | if ( val!= 1.0 ) { |
| 438 | DensityStatecxx . . $ NCrystal/DensityState# dscxx . . $ NCrystal/DensityState#DensityState(ced63f7c635d850d).; |
| 439 | ds.typecxx . . $ NCrystal/DensityState#type. = DensityStatecxx . . $ NCrystal/DensityState#::Typecxx . . $ NCrystal/DensityState#Type#::SCALEFACTORcxx . . $ NCrystal/DensityState#Type#SCALEFACTOR.; |
| 440 | ds.valuecxx . . $ NCrystal/DensityState#value. = val; |
| 441 | set_densitycxx . . $ NCrystal/MatCfg#set_density(cf59eba3bb5081c6).(ds); |
| 442 | } |
| 443 | } |
| 444 | inline stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& operatorcxx . . $ NCrystal/`operator<<`(698ba43f8163e7b3).<< (stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& os, const MatCfgcxx . . $ NCrystal/MatCfg#& cfg) { cfg.dumpcxx . . $ NCrystal/MatCfg#dump(25a4e5f405a65361).(os,false); return os; } |
| 445 | |
| 446 | } |
| 447 | |
| 448 | #endif |