diff --git a/src/modules/mesh/moduleMeshBoundary.f90 b/src/modules/mesh/moduleMeshBoundary.f90 index 5320aa0..37fa3cc 100644 --- a/src/modules/mesh/moduleMeshBoundary.f90 +++ b/src/modules/mesh/moduleMeshBoundary.f90 @@ -261,12 +261,12 @@ MODULE moduleMeshBoundary energy = (eRel - bound%energyThreshold) * PI2 / (PI2 + theta**2) + bound%energyThreshold !Get number of secondary electrons particles - yield = part%weight*bound%yield%get(eRel) * (1.D0 * theta**2 / PI2) !Check equation! + yield = part%weight*bound%yield%get(eRel) * (1.D0 * theta**2 / PI2) !Convert the number to macro-particles nNewElectrons = FLOOR(yield / bound%electron%weight) - !If the weight of new macro-particles is below the yield, correct adding a particle + !If the weight of new macro-particles is below the yield, add an additional particle with less weight IF (REAL(nNewElectrons) * bound%electron%weight < yield) THEN nNewElectrons = nNewElectrons + 1 ALLOCATE(weight(1:nNewElectrons)) @@ -310,7 +310,9 @@ MODULE moduleMeshBoundary secondaryElectron%n_in = .TRUE. !Assign velocity - secondaryElectron%v = 2.D0 * edge%normal + 1.D-1 * (/ randomMaxwellian(), randomMaxwellian(), randomMaxwellian() /) + !TODO: Calculate energy and velocity + !TODO: Better way to inject particles from surface. For this and for general injection + secondaryElectron%v = 1.D0 * edge%normal + 1.D-1 * (/ randomMaxwellian(), randomMaxwellian(), randomMaxwellian() /) !Add particle to list CALL partSurfaces%setLock() diff --git a/src/modules/moduleInject.f90 b/src/modules/moduleInject.f90 index f4c9c46..41f7626 100644 --- a/src/modules/moduleInject.f90 +++ b/src/modules/moduleInject.f90 @@ -367,14 +367,11 @@ MODULE moduleInject self%v(2)%obj%randomVel(), & self%v(3)%obj%randomVel() /) - !For each direction, velocities have to agree with the direction of injection - DO j = 1, 3 - DO WHILE (partInj(n)%v(i)*direction(i) < 0) - partInj(n)%v(i) = self%vMod*direction(i) + self%v(i)%obj%randomVel() + !If velocity is not in the right direction, invert it + IF (DOT_PRODUCT(direction, partInj(n)%v) < 0.D0) THEN + partInj(n)%v = - partInj(n)%v - END DO - - END DO + END IF !Obtain natural coordinates of particle in cell partInj(n)%Xi = mesh%cells(partInj(n)%cell)%obj%phy2log(partInj(n)%r)