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