This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maxwell.f
63 lines (50 loc) · 1.71 KB
/
maxwell.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
************************************************************************
* *
SUBROUTINE MAXWELL(TMP,VX,VY,VZ,EI)
* *
* Subroutine per la generazione di velocita ed energie secondo *
* una distribuzione di Maxwell tramite l argoritmo di Box-Mueller *
* *
************************************************************************
***** VARIABILI ********************************************************
***** INPUT
* temperatura
REAL*8 TMP
***** OUTPUT
* componenti della velocita
REAL*8 VX,VY,VZ
* energia interna
REAL*8 EI
***** VARIABILI LOCALI
* due volte pi greco
REAL*8,PARAMETER::PI2=6.2831853071795864
* radice quadrata della temperatura
REAL*8 SIGMA
* numero casuale da distribuzione uniforme
REAL*8 R
* coordinate polari
REAL*8 RHO,THETA
***** FINE VARIABILI ***************************************************
SIGMA=DSQRT(TMP)
* genero modulo velocita nel piano yz
R=1.D0-RAND()
RHO=DSQRT(-2.D0*DLOG(R))
* genero coordinata angolare
R=RAND()
THETA=PI2*R
* calcolo coordinate yz della velocita
VY=RHO*DCOS(THETA)*SIGMA
VZ=RHO*DSIN(THETA)*SIGMA
* genero modulo per x
R=1.D0-RAND()
RHO=DSQRT(-2.D0*DLOG(R))
* genero angolo per x
R=RAND()
THETA=PI2*R
VX=RHO*DCOS(THETA)*SIGMA
* genero valore energia interna
R=1.D0-RAND()
EI=-DLOG(R)*TMP
RETURN
END
***** FINE SUBROUTINEMAXWELL *******************************************