Skip to content

Commit 724471f

Browse files
Merge pull request #510 from Warwick-Plasma/photon_bug_fix
Photon initialisation fix (issue #502)
2 parents fdfd6f3 + d187a5e commit 724471f

File tree

6 files changed

+63
-0
lines changed

6 files changed

+63
-0
lines changed

epoch1d/src/physics_packages/injectors.F90

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,13 @@ SUBROUTINE run_single_injector(injector)
307307
#ifndef PER_SPECIES_WEIGHT
308308
density = MIN(density, injector%density_max)
309309
new%weight = weight_fac * density
310+
#endif
311+
#if defined(PHOTONS) || defined(BREMSSTRAHLUNG)
312+
! For photons, assign additional variable used in photon particle-push
313+
IF (species_list(injector%species)%species_type == c_species_id_photon) &
314+
THEN
315+
new%particle_energy = SQRT(SUM(new%part_p**2)) * c
316+
END IF
310317
#endif
311318
CALL add_particle_to_partlist(plist, new)
312319
END DO

epoch1d/src/user_interaction/helper.F90

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ SUBROUTINE auto_load
9292
TYPE(particle_species), POINTER :: species
9393
INTEGER :: i0, i1, iu, io
9494
TYPE(initial_condition_block), POINTER :: ic
95+
#if defined(PHOTONS) || defined(BREMSSTRAHLUNG)
96+
TYPE(particle), POINTER :: current
97+
#endif
9598

9699
IF (pre_loading .AND. n_species > 0) THEN
97100
i0 = 1 - ng
@@ -141,6 +144,17 @@ SUBROUTINE auto_load
141144
ELSE IF (species%ic_df_type == c_ic_df_arbitrary) THEN
142145
CALL setup_particle_dist_fn(species, species_drift)
143146
END IF
147+
148+
#if defined(PHOTONS) || defined(BREMSSTRAHLUNG)
149+
! For photons, assign additional variable used in photon particle-push
150+
IF (species_list(ispecies)%species_type == c_species_id_photon) THEN
151+
current => species%attached_list%head
152+
DO WHILE (ASSOCIATED(current))
153+
current%particle_energy = SQRT(SUM(current%part_p**2)) * c
154+
current => current%next
155+
END DO
156+
END IF
157+
#endif
144158
END DO
145159

146160
IF (pre_loading) RETURN

epoch2d/src/physics_packages/injectors.F90

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,13 @@ SUBROUTINE run_single_injector(injector)
366366
#ifndef PER_SPECIES_WEIGHT
367367
density = MIN(density, injector%density_max)
368368
new%weight = weight_fac * density
369+
#endif
370+
#if defined(PHOTONS) || defined(BREMSSTRAHLUNG)
371+
! For photons, assign additional variable used in photon particle-push
372+
IF (species_list(injector%species)%species_type == c_species_id_photon) &
373+
THEN
374+
new%particle_energy = SQRT(SUM(new%part_p**2)) * c
375+
END IF
369376
#endif
370377
CALL add_particle_to_partlist(plist, new)
371378
END DO

epoch2d/src/user_interaction/helper.F90

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ SUBROUTINE auto_load
9898
TYPE(particle_species), POINTER :: species
9999
INTEGER :: i0, i1, iu, io
100100
TYPE(initial_condition_block), POINTER :: ic
101+
#if defined(PHOTONS) || defined(BREMSSTRAHLUNG)
102+
TYPE(particle), POINTER :: current
103+
#endif
101104

102105
IF (pre_loading .AND. n_species > 0) THEN
103106
i0 = 1 - ng
@@ -147,6 +150,17 @@ SUBROUTINE auto_load
147150
ELSE IF (species%ic_df_type == c_ic_df_arbitrary) THEN
148151
CALL setup_particle_dist_fn(species, species_drift)
149152
END IF
153+
154+
#if defined(PHOTONS) || defined(BREMSSTRAHLUNG)
155+
! For photons, assign additional variable used in photon particle-push
156+
IF (species_list(ispecies)%species_type == c_species_id_photon) THEN
157+
current => species%attached_list%head
158+
DO WHILE (ASSOCIATED(current))
159+
current%particle_energy = SQRT(SUM(current%part_p**2)) * c
160+
current => current%next
161+
END DO
162+
END IF
163+
#endif
150164
END DO
151165

152166
IF (pre_loading) RETURN

epoch3d/src/physics_packages/injectors.F90

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,13 @@ SUBROUTINE run_single_injector(injector)
403403
#ifndef PER_SPECIES_WEIGHT
404404
density = MIN(density, injector%density_max)
405405
new%weight = weight_fac * density
406+
#endif
407+
#if defined(PHOTONS) || defined(BREMSSTRAHLUNG)
408+
! For photons, assign additional variable used in photon particle-push
409+
IF (species_list(injector%species)%species_type == c_species_id_photon) &
410+
THEN
411+
new%particle_energy = SQRT(SUM(new%part_p**2)) * c
412+
END IF
406413
#endif
407414
CALL add_particle_to_partlist(plist, new)
408415
END DO

epoch3d/src/user_interaction/helper.F90

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ SUBROUTINE auto_load
104104
TYPE(particle_species), POINTER :: species
105105
INTEGER :: i0, i1, iu, io
106106
TYPE(initial_condition_block), POINTER :: ic
107+
#if defined(PHOTONS) || defined(BREMSSTRAHLUNG)
108+
TYPE(particle), POINTER :: current
109+
#endif
107110

108111
IF (pre_loading .AND. n_species > 0) THEN
109112
i0 = 1 - ng
@@ -153,6 +156,17 @@ SUBROUTINE auto_load
153156
ELSE IF (species%ic_df_type == c_ic_df_arbitrary) THEN
154157
CALL setup_particle_dist_fn(species, species_drift)
155158
END IF
159+
160+
#if defined(PHOTONS) || defined(BREMSSTRAHLUNG)
161+
! For photons, assign additional variable used in photon particle-push
162+
IF (species_list(ispecies)%species_type == c_species_id_photon) THEN
163+
current => species%attached_list%head
164+
DO WHILE (ASSOCIATED(current))
165+
current%particle_energy = SQRT(SUM(current%part_p**2)) * c
166+
current => current%next
167+
END DO
168+
END IF
169+
#endif
156170
END DO
157171

158172
IF (pre_loading) RETURN

0 commit comments

Comments
 (0)