Warning, file /include/celeritas/phys/PhysicsData.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include "corecel/data/Collection.hh"
0010 #include "corecel/data/CollectionBuilder.hh"
0011 #include "corecel/data/StackAllocatorData.hh"
0012 #include "celeritas/Quantities.hh"
0013 #include "celeritas/Types.hh"
0014 #include "celeritas/em/data/AtomicRelaxationData.hh"
0015 #include "celeritas/em/data/EPlusGGData.hh"
0016 #include "celeritas/em/data/ElectroNuclearData.hh"
0017 #include "celeritas/em/data/GammaNuclearData.hh"
0018 #include "celeritas/em/data/LivermorePEData.hh"
0019 #include "celeritas/grid/XsGridData.hh"
0020 #include "celeritas/neutron/data/NeutronElasticData.hh"
0021
0022 #include "Interaction.hh"
0023 #include "Secondary.hh"
0024
0025 namespace celeritas
0026 {
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 template<class GridId>
0039 struct ValueTable
0040 {
0041 ItemRange<GridId> grids;
0042
0043
0044 explicit CELER_FUNCTION operator bool() const { return !grids.empty(); }
0045 };
0046
0047 using UniformTable = ValueTable<UniformGridId>;
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 struct ModelCdfTable
0060 {
0061 ItemRange<UniformTable> tables;
0062
0063
0064 explicit CELER_FUNCTION operator bool() const { return !tables.empty(); }
0065 };
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076 struct ModelGroup
0077 {
0078 using Energy = units::MevEnergy;
0079
0080 ItemRange<real_type> energy;
0081 ItemRange<ParticleModelId> model;
0082
0083
0084 explicit CELER_FUNCTION operator bool() const
0085 {
0086 return (energy.size() >= 2) && (model.size() + 1 == energy.size());
0087 }
0088 };
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100 struct IntegralXsProcess
0101 {
0102 ItemRange<real_type> energy_max_xs;
0103
0104
0105 explicit CELER_FUNCTION operator bool() const
0106 {
0107 return !energy_max_xs.empty();
0108 }
0109 };
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127 struct ProcessGroup
0128 {
0129 ItemRange<ProcessId> processes;
0130 ItemRange<ModelGroup> models;
0131 ItemRange<IntegralXsProcess> integral_xs;
0132 ItemRange<ValueTable<XsGridId>> macro_xs;
0133 UniformTable energy_loss;
0134 UniformTable range;
0135 UniformTable inverse_range;
0136 ParticleProcessId at_rest;
0137
0138
0139 explicit CELER_FUNCTION operator bool() const
0140 {
0141 return !processes.empty() && models.size() == processes.size();
0142 }
0143
0144
0145 CELER_FUNCTION ParticleProcessId::size_type size() const
0146 {
0147 return processes.size();
0148 }
0149 };
0150
0151
0152
0153
0154
0155 struct HardwiredIds
0156 {
0157 ProcessId annihilation;
0158 ModelId eplusgg;
0159
0160 ProcessId electro_nuclear;
0161 ModelId electro_vd;
0162
0163 ProcessId gamma_nuclear;
0164 ModelId bertini_qgs;
0165
0166 ProcessId photoelectric;
0167 ModelId livermore_pe;
0168
0169 ProcessId neutron_elastic;
0170 ModelId chips;
0171 };
0172
0173
0174
0175
0176
0177 template<Ownership W, MemSpace M>
0178 struct HardwiredModels
0179 {
0180
0181 HardwiredIds ids;
0182
0183
0184 EPlusGGData eplusgg;
0185 ElectroNuclearData<W, M> electro_vd;
0186 GammaNuclearData<W, M> bertini_qgs;
0187 LivermorePEData<W, M> livermore_pe;
0188 AtomicRelaxParamsData<W, M> relaxation;
0189 NeutronElasticData<W, M> chips;
0190
0191
0192 template<Ownership W2, MemSpace M2>
0193 HardwiredModels& operator=(HardwiredModels<W2, M2> const& other)
0194 {
0195
0196 ids = other.ids;
0197 eplusgg = other.eplusgg;
0198
0199 return *this;
0200 }
0201 };
0202
0203
0204
0205
0206
0207
0208
0209
0210 struct ParticleScalars
0211 {
0212 using Energy = units::MevEnergy;
0213
0214
0215 real_type min_range{};
0216 real_type max_step_over_range{};
0217 Energy lowest_energy{};
0218
0219
0220 bool displaced{};
0221 real_type range_factor{};
0222 MscStepLimitAlgorithm step_limit_algorithm{MscStepLimitAlgorithm::size_};
0223
0224
0225 explicit CELER_FUNCTION operator bool() const
0226 {
0227 return min_range > 0 && max_step_over_range > 0
0228 && lowest_energy > zero_quantity() && range_factor > 0
0229 && range_factor < 1
0230 && step_limit_algorithm != MscStepLimitAlgorithm::size_;
0231 }
0232 };
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245 struct PhysicsParamsScalars
0246 {
0247 using Energy = units::MevEnergy;
0248
0249
0250 ProcessId::size_type max_particle_processes{};
0251
0252 ActionId first_model_action{};
0253
0254 ModelId::size_type num_models{};
0255
0256
0257 real_type min_eprime_over_e{};
0258 real_type linear_loss_limit{};
0259 real_type fixed_step_limiter{};
0260
0261
0262 real_type lambda_limit{};
0263 real_type safety_factor{};
0264
0265
0266 ParticleScalars light;
0267 ParticleScalars heavy;
0268
0269 real_type secondary_stack_factor = 3;
0270
0271
0272 ActionId fixed_step_action{};
0273
0274
0275 explicit CELER_FUNCTION operator bool() const
0276 {
0277 return max_particle_processes > 0 && first_model_action >= ActionId{4}
0278 && num_models > 0 && min_eprime_over_e > 0
0279 && linear_loss_limit > 0 && secondary_stack_factor > 0
0280 && ((fixed_step_limiter > 0)
0281 == static_cast<bool>(fixed_step_action))
0282 && lambda_limit > 0 && safety_factor >= 0.1 && light && heavy;
0283 }
0284
0285
0286 CELER_FORCEINLINE_FUNCTION ActionId msc_action() const
0287 {
0288 return first_model_action - 4;
0289 }
0290
0291
0292 CELER_FORCEINLINE_FUNCTION ActionId range_action() const
0293 {
0294 return first_model_action - 3;
0295 }
0296
0297
0298 CELER_FORCEINLINE_FUNCTION ActionId discrete_action() const
0299 {
0300 return first_model_action - 2;
0301 }
0302
0303
0304 CELER_FORCEINLINE_FUNCTION ActionId integral_rejection_action() const
0305 {
0306 return first_model_action - 1;
0307 }
0308
0309
0310 CELER_FORCEINLINE_FUNCTION ActionId failure_action() const
0311 {
0312 return first_model_action + num_models;
0313 }
0314 };
0315
0316
0317
0318
0319
0320
0321
0322
0323
0324 template<Ownership W, MemSpace M>
0325 struct PhysicsParamsData
0326 {
0327
0328
0329 template<class T>
0330 using Items = Collection<T, W, M>;
0331 template<class T>
0332 using ParticleItems = Collection<T, W, M, ParticleId>;
0333 template<class T>
0334 using ParticleModelItems = Collection<T, W, M, ParticleModelId>;
0335
0336
0337
0338
0339 PhysicsParamsScalars scalars;
0340
0341
0342 HardwiredModels<Ownership::const_reference, M> hardwired;
0343
0344
0345 Items<XsGridId> xs_grid_ids;
0346 Items<XsGridRecord> xs_grids;
0347 Items<ValueTable<XsGridId>> xs_tables;
0348 Items<UniformGridId> uniform_grid_ids;
0349 Items<UniformGridRecord> uniform_grids;
0350 Items<UniformTable> uniform_tables;
0351 ParticleModelItems<ModelCdfTable> model_cdf;
0352
0353
0354 Items<ModelGroup> model_groups;
0355 Items<IntegralXsProcess> integral_xs;
0356 ParticleItems<ProcessGroup> process_groups;
0357 ParticleModelItems<ModelId> model_ids;
0358 Items<ParticleModelId> pmodel_ids;
0359 Items<ProcessId> process_ids;
0360
0361
0362 Items<real_type> reals;
0363
0364
0365
0366
0367 explicit CELER_FUNCTION operator bool() const
0368 {
0369 return !process_groups.empty() && !model_ids.empty() && scalars;
0370 }
0371
0372
0373 template<Ownership W2, MemSpace M2>
0374 PhysicsParamsData& operator=(PhysicsParamsData<W2, M2> const& other)
0375 {
0376 CELER_EXPECT(other);
0377
0378 scalars = other.scalars;
0379
0380 hardwired = other.hardwired;
0381
0382 xs_grids = other.xs_grids;
0383 xs_grid_ids = other.xs_grid_ids;
0384 xs_tables = other.xs_tables;
0385 uniform_grids = other.uniform_grids;
0386 uniform_grid_ids = other.uniform_grid_ids;
0387 uniform_tables = other.uniform_tables;
0388 model_cdf = other.model_cdf;
0389
0390 model_groups = other.model_groups;
0391 integral_xs = other.integral_xs;
0392 process_groups = other.process_groups;
0393 model_ids = other.model_ids;
0394 pmodel_ids = other.pmodel_ids;
0395 process_ids = other.process_ids;
0396
0397 reals = other.reals;
0398
0399 return *this;
0400 }
0401 };
0402
0403
0404
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419 struct PhysicsTrackState
0420 {
0421 real_type interaction_mfp;
0422
0423
0424 real_type macro_xs;
0425 real_type energy_deposition;
0426 real_type dedx_range;
0427 MscRange msc_range;
0428 Span<Secondary> secondaries;
0429 ElementComponentId element;
0430 };
0431
0432
0433
0434
0435
0436
0437
0438
0439 struct PhysicsTrackInitializer
0440 {
0441 };
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451
0452 template<Ownership W, MemSpace M>
0453 struct PhysicsStateData
0454 {
0455
0456
0457 template<class T>
0458 using StateItems = celeritas::StateCollection<T, W, M>;
0459 template<class T>
0460 using Items = celeritas::Collection<T, W, M>;
0461
0462
0463
0464 StateItems<PhysicsTrackState> state;
0465 StateItems<MscStep> msc_step;
0466
0467 Items<real_type> per_process_xs;
0468
0469 AtomicRelaxStateData<W, M> relaxation;
0470 StackAllocatorData<Secondary, W, M> secondaries;
0471
0472
0473
0474
0475 explicit CELER_FUNCTION operator bool() const
0476 {
0477 return !state.empty() && secondaries;
0478 }
0479
0480
0481 CELER_FUNCTION size_type size() const { return state.size(); }
0482
0483
0484 template<Ownership W2, MemSpace M2>
0485 PhysicsStateData& operator=(PhysicsStateData<W2, M2>& other)
0486 {
0487 CELER_EXPECT(other);
0488 state = other.state;
0489 msc_step = other.msc_step;
0490
0491 per_process_xs = other.per_process_xs;
0492
0493 relaxation = other.relaxation;
0494 secondaries = other.secondaries;
0495
0496 return *this;
0497 }
0498 };
0499
0500
0501
0502
0503
0504 template<MemSpace M>
0505 inline void resize(PhysicsStateData<Ownership::value, M>* state,
0506 HostCRef<PhysicsParamsData> const& params,
0507 size_type size)
0508 {
0509 CELER_EXPECT(size > 0);
0510 CELER_EXPECT(params.scalars.max_particle_processes > 0);
0511 resize(&state->state, size);
0512 resize(&state->msc_step, size);
0513 resize(&state->per_process_xs,
0514 size * params.scalars.max_particle_processes);
0515 resize(&state->relaxation, params.hardwired.relaxation, size);
0516 resize(
0517 &state->secondaries,
0518 static_cast<size_type>(size * params.scalars.secondary_stack_factor));
0519 }
0520
0521
0522 }