MoDeNa  1.0
Software framework facilitating sequential multi-scale modelling
input_output.f90
1 !WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
2 ! SUBROUTINE INPUT
3 !
4 ! This subroutine draws user input data from the file
5 ! INPUT.INP which is located: ./INPUT_FILE/INPUT.INP
6 ! This subroutine also provides all pure component parameters as
7 ! well as kij's. (At the end of this routine, the SUBROUTINE
8 ! PARA_INPUT is called, which delivers these pure component
9 ! parameters.)
10 !
11 ! SUMMERY OF OUTPUT VARIABLES:
12 ! eos type of equation of state ( 1 = PC-SAFT )
13 ! T, P, ncomp temperature, pressure, number of components
14 ! xiF array of feed molefractions. For binary mixtures
15 ! most calculation options don't require a definition
16 ! of feed molefractions. Rather, values are generated
17 ! automatically if all feed molefractions are set to
18 ! zero in the INPUT-file.
19 ! parame array of pure component parameters. See
20 ! SUBROUTINE PARA_INPUT (in file: para_input.f)
21 ! compna, mm name (string) and molec.mass of pure component
22 ! kij binary interaction parameter
23 ! uinT,uinP units of T and p for input and all outputs
24 !WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
25 
26 SUBROUTINE read_input
27 
28  USE basic_variables
29  use utilities, only: file_open
30  IMPLICIT NONE
31 
32  !-----------------------------------------------------------------------------
33  INTEGER :: i
34  REAL :: reading2,reading3,sumfeed
35  CHARACTER (LEN=4) :: uoutp, uinp
36  CHARACTER (LEN=1) :: uoutt, uint
37  CHARACTER (LEN=50) :: filename
38  CHARACTER (LEN=30) :: reading1
39  !-----------------------------------------------------------------------------
40 
41  filename = './in.txt'
42  CALL file_open(filename,30)
43 ! READ (30,*) eos, pol
44  eos = 1
45  pol = 1
46 
47  !READ (30,*) t, uint, p, uinp
48  READ(30,*) t
49  uint = 'K'
50  p = 1.
51  uinp = 'bar'
52 
53 
54 
55 ! ncomp = 0
56 ! i = 0
57 ! sumfeed = 0.0
58 ! read_loop: DO
59 ! READ (30,*) reading1,reading2,reading3
60 ! IF (reading1 == 'end') EXIT read_loop
61 ! ncomp = ncomp + 1
62 ! i = i + 1
63 ! compna(i)= reading1 ! comp.name
64 ! mm(i) = reading2 ! molec.mass (mandatory only for polymers)
65 ! xif(i) = reading3
66 ! sumfeed = sumfeed + xif(i)
67 ! ENDDO read_loop
68 
69  READ(30,*) ncomp !read number of components present in system
70  READ(30,*) compna(1) !read name of component which the solubility is calculated for
71  sumfeed = 0.
72  Do i = 1,ncomp !read composition of liquid phase
73  mm(i) = 0.
74  READ(30,*) xif(i)
75  sumfeed = sumfeed + xif(i)
76  End Do
77 
78 
79  !Determine wheter two component system (-> solubility in polyurethane polymer)
80  !Or three component system (-> solubility in reaction mixture consisting of polyol and MDI)
81  If(ncomp == 2) Then
82  compna(2) = 'pu'
83  Else If (ncomp == 3) Then
84  compna(2) = 'polyol'!'hexane'
85  compna(3) = 'mdi'!'butane'
86  Else
87  write(*,*) 'Solubility Code: This code is only for systems with 2 or 3 components!'
88  stop 5
89  End If
90 
91 
92  CLOSE (30)
93 
94  IF ( sumfeed /= 0.0 .AND. sumfeed /= 1.0 ) THEN
95  xif(1:ncomp) = xif(1:ncomp)/sumfeed
96  END IF
97 
98  uoutt = uint
99  uoutp = uinp
100  IF (uint == 'C' ) THEN
101  u_in_t = 273.15
102  ELSE
103  u_in_t = 0.0
104  END IF
105  IF ( uinp == 'bar' ) THEN
106  u_in_p = 1.e5
107  ELSE IF ( uinp == 'mbar' ) THEN
108  u_in_p = 1.e2
109  ELSE IF ( uinp == 'MPa' ) THEN
110  u_in_p = 1.e6
111  ELSE IF ( uinp == 'kPa' ) THEN
112  u_in_p = 1.e3
113  ELSE
114  u_in_p = 1.e0
115  END IF
116 
117  IF ( uoutt == 'C' ) THEN
118  u_out_t = 273.15
119  ELSE
120  u_out_t = 0.0
121  END IF
122  IF ( uoutp == 'bar' ) THEN
123  u_out_p = 1.e5
124  ELSE IF ( uoutp == 'mbar' ) THEN
125  u_out_p = 1.e2
126  ELSE IF ( uoutp == 'MPa' ) THEN
127  u_out_p = 1.e6
128  ELSE IF ( uoutp == 'kPa' ) THEN
129  u_out_p = 1.e3
130  ELSE
131  u_out_p = 1.0
132  END IF
133 
134  t = t + u_in_t
135  p = p * u_in_p
136 
137  CALL para_input ! retriev pure comp. parameters
138 
139  IF (ncomp == 1) THEN
140  WRITE (40,*) ' T P rho_1 rho_2 h_LV'
141  ELSE IF (ncomp == 2) THEN
142  ! WRITE (40,*) ' x2_phase1 x2_phase2 w1_phase1 w2_phase2 T P rho1 rho2'
143  WRITE (40,*) ' '
144  ELSE IF (ncomp == 3) THEN
145  WRITE (40,*) ' x1_ph1 x2_ph1 x3_ph1 x1_ph2 x2_ph2 x3_ph2 T P rho1 rho2'
146  END IF
147 
148 END SUBROUTINE read_input
149 
150 
151 
152 !WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
153 ! SUBROUTINE OUTPUT
154 !
155 ! The purpose of this subroutine is obvious.
156 !WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
157 
158 SUBROUTINE output
159 
160  USE basic_variables
161  use utilities, only: si_dens
162  IMPLICIT NONE
163 
164  !-----------------------------------------------------------------------------
165  INTEGER :: i
166  CHARACTER (LEN=4) :: t_ind
167  CHARACTER (LEN=4) :: p_ind
168  CHARACTER (LEN=4) :: char_ncomp
169  REAL :: density(np),w(np,nc)
170  !-----------------------------------------------------------------------------
171 
172  CALL si_dens ( density, w )
173 
174  IF ( u_in_p == 1.e5 ) THEN
175  p_ind = ' bar'
176  ELSE IF ( u_in_p == 1.e2 ) THEN
177  p_ind = 'mbar'
178  ELSE IF ( u_in_p == 1.e6 ) THEN
179  p_ind = ' MPa'
180  ELSE IF ( u_in_p == 1.e3 ) THEN
181  p_ind = ' kPa'
182  ELSE
183  p_ind = ' Pa'
184  END IF
185  IF ( u_in_t == 273.15 ) THEN
186  t_ind = ' C'
187  ELSE
188  t_ind = ' K'
189  END IF
190 
191  WRITE(*,*) '--------------------------------------------------'
192  WRITE (char_ncomp,'(I3)') ncomp
193  WRITE(*,'(t2,a,f7.2,2a,f9.4,a)') ' T =',t-u_out_t,t_ind &
194  ,' P =',p/u_out_p,p_ind
195  WRITE(*,'(t15,4(a12,1x),10x,a)') (compna(i),i=1,ncomp)
196  WRITE(*,'(2x,a,'//char_ncomp//'(g13.6,1x))') 'PHASE I w', (w(1,i),i=1,ncomp)
197  WRITE(*,'(2x,a,'//char_ncomp//'(g13.6,1x))') 'PHASE II w', (w(2,i),i=1,ncomp)
198  WRITE(*,'(2x,a,'//char_ncomp//'(g13.6,1x))') 'PHASE I x', (exp(lnx(1,i)),i=1,ncomp)
199  WRITE(*,'(2x,a,'//char_ncomp//'(g13.6,1x))') 'PHASE II x', (exp(lnx(2,i)),i=1,ncomp)
200  WRITE(*,'(2x,a,2(g13.6,1x))') 'DENSITY ', density(1),density(2)
201 
202  !-----------------------------------------------------------------------------
203  ! output to files
204  !-----------------------------------------------------------------------------
205  IF ( ncomp == 1 ) THEN
206  WRITE (40,'(9(2x,f18.8))') t-u_out_t, p/u_out_p, &
207  density(1), density(2),h_lv,cpres(1),cpres(2), &
208  speed_of_sound(1),speed_of_sound(2)
209  ! & ,(enthal(2)-enthal(1))/mm(1)
210  ! WRITE (40,'(4(2x,f15.8))') t, p, 0.3107*dense(1)
211  ! & /0.1617*(0.689+0.311*(T/1.328)**0.3674),0.3107
212  ! & *dense(2)/0.1617*(0.689+0.311*(T/1.328)**0.3674)
213  ELSE IF ( ncomp == 2 ) THEN
214  WRITE (40,'(12(2x,G15.8))') 1.0-xi(1,1),1.0-xi(2,1), &
215  w(1,1),w(2,1),t-u_out_t, p/u_out_p, density(1),density(2) &
216  ,enthal(1),enthal(2),cpres(1),cpres(2)
217  ELSE IF ( ncomp == 3 ) THEN
218  WRITE (40,'(10(2x,f15.8))') xi(1,1),xi(1,2),xi(1,3),xi(2,1),xi(2,2), &
219  xi(2,3),t-u_out_t, p/u_out_p, density(1),density(2)
220  END IF
221 
222 END SUBROUTINE output
223 
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW This module contains paramete...
Definition: modules.f90:29