66 lines
1.7 KiB
Fortran
66 lines
1.7 KiB
Fortran
!Contains the information about species (particles)
|
|
MODULE moduleSpecies
|
|
USE moduleCaseParam
|
|
IMPLICIT NONE
|
|
|
|
TYPE, ABSTRACT:: speciesGeneric
|
|
CHARACTER(:), ALLOCATABLE:: name
|
|
REAL(8):: m=0.D0, weight=0.D0
|
|
INTEGER:: pt=0
|
|
END TYPE speciesGeneric
|
|
|
|
TYPE, EXTENDS(speciesGeneric):: speciesNeutral
|
|
|
|
END TYPE speciesNeutral
|
|
|
|
TYPE, EXTENDS(speciesGeneric):: speciesCharged
|
|
REAL(8):: q=0.D0, qm=0.D0
|
|
|
|
END TYPE speciesCharged
|
|
|
|
TYPE:: speciesCont
|
|
CLASS(speciesGeneric), ALLOCATABLE:: obj
|
|
|
|
END TYPE
|
|
|
|
INTEGER:: nSpecies
|
|
TYPE(speciesCont), ALLOCATABLE:: species(:)
|
|
|
|
TYPE particle
|
|
REAL(8):: r(1:3) !Position
|
|
REAL(8):: v(1:3) !Velocity
|
|
INTEGER:: pt !Particle species id
|
|
INTEGER:: e_p !Index of element in which the particle is located
|
|
REAL(8):: xLog(1:2) !Logical coordinates of particle in element e_p.
|
|
LOGICAL:: n_in !Flag that indicates if a particle is in the domain
|
|
REAL(8):: weight=0.D0
|
|
|
|
END TYPE particle
|
|
|
|
!Number of old particles
|
|
INTEGER:: nPartOld
|
|
INTEGER:: nPartInj
|
|
!Arrays that contain the particles
|
|
TYPE(particle), ALLOCATABLE, DIMENSION(:), TARGET:: partOld !array of particles from previous iteration
|
|
TYPE(particle), ALLOCATABLE, DIMENSION(:), TARGET:: partInj !array of inject particles
|
|
|
|
CONTAINS
|
|
FUNCTION speciesName2Index(speciesName) RESULT(pt)
|
|
IMPLICIT NONE
|
|
|
|
CHARACTER(:), ALLOCATABLE:: speciesName
|
|
INTEGER:: pt
|
|
INTEGER:: n
|
|
|
|
pt = 0
|
|
DO n = 1, nSpecies
|
|
IF (speciesName == species(n)%obj%name) THEN
|
|
pt = species(n)%obj%pt
|
|
EXIT
|
|
END IF
|
|
END DO
|
|
!TODO: add error handling when species not found
|
|
|
|
END FUNCTION speciesName2Index
|
|
|
|
END MODULE moduleSpecies
|