Revision | 14bab3c9776bff028afead1fb45e75b0fd83ac94 (tree) |
---|---|
Zeit | 2007-01-30 20:37:41 |
Autor | iselllo |
Commiter | iselllo |
This time a major update of the code R-codes/plot-boundary.R. Now the
code is able to read a velocity profile and a concentration profile and
work out the axial flux considering separately the contributions of the
layer and of the core. Careful about the input data files: temperature
and velocities may be defined on different domains and have a different
number of non-zero elements.
@@ -2,17 +2,30 @@ | ||
2 | 2 | solution<-read.table("boundary.txt",header=TRUE,nrow=20000) |
3 | 3 | solution<-as.matrix(solution) |
4 | 4 | delta<-abs(solution[300,1]-solution[299,1]) |
5 | -#zero<-which(solution[ ,2]==0) | |
6 | -#zero<-as.vector(zero) | |
7 | -#zero<-zero[1] | |
8 | -#end_sol<-zero-1 | |
5 | + | |
6 | + | |
7 | +# routine for integration | |
8 | +def_integral<-function(integrand,h) | |
9 | +{ | |
10 | +n<-length(integrand) | |
11 | +myseq<-seq(1,n-4,4) | |
12 | +integral<-0 | |
13 | +for (i in myseq) | |
14 | +{ | |
15 | +integral<- integral + h/45.0*(14.0*integrand[i]+64.0*integrand[i+1] +24.0*integrand[i+2]+64.0*integrand[i+3]+14.0*integrand[i+4]) | |
16 | + | |
17 | +} | |
18 | +return(integral) | |
19 | +} | |
20 | + | |
21 | + | |
9 | 22 | vecdim<-dim(solution) |
10 | 23 | end_sol<-vecdim[1] |
11 | 24 | solution<-solution[1:end_sol, ] # numerical solution up to the wall |
12 | 25 | # where it is still non-zero and it has to be corrected |
13 | 26 | r_wall<-0.15895 |
14 | 27 | layer_thickness<-2.5e-3 |
15 | -viscous_length<-2.5e-3/30 # either I first define the layer thickness and then I found out how many viscous lengths it amounts to, or I start from the viscous length times the number of lengths amounting to the layer thickness. | |
28 | +viscous_length<-2.5e-3/150 # either I first define the layer thickness and then I found out how many viscous lengths it amounts to, or I start from the viscous length times the number of lengths amounting to the layer thickness. | |
16 | 29 | |
17 | 30 | |
18 | 31 |
@@ -30,7 +43,10 @@ | ||
30 | 43 | n_viscous<-as.integer(layer_thickness/viscous_length) |
31 | 44 | n_delta<-as.integer(layer_thickness/delta) |
32 | 45 | |
33 | -end_sol<-end_sol-n_delta | |
46 | +end_sol<-end_sol-n_delta-1 # I added a -1 for better compatibility wrt what I am doing below | |
47 | + | |
48 | +print("end_sol is") | |
49 | +print(end_sol) | |
34 | 50 | |
35 | 51 | solution<-solution[1:end_sol, ] # numerical solution up to the point where it is joined to |
36 | 52 | # the analytical expression |
@@ -46,20 +62,27 @@ | ||
46 | 62 | |
47 | 63 | wall_arr<-wall_fun()/norm_factor*solution[end_sol,2] |
48 | 64 | |
65 | + | |
66 | + | |
49 | 67 | pdf("wall_profile.pdf") |
50 | 68 | plot(y_plus,wall_arr,"l",lwd=2,col="blue",ylab="velocity profile",xlab="distance from wall in wall units") |
51 | 69 | dev.off() |
52 | 70 | |
71 | + | |
72 | + | |
53 | 73 | y_plus<-y_plus*viscous_length |
54 | 74 | y_plus<-sort(y_plus,decreasing=FALSE)+solution[end_sol,1] |
55 | 75 | |
56 | 76 | |
77 | + | |
78 | + | |
57 | 79 | pdf("wall_profile2.pdf") |
58 | 80 | plot(y_plus ,wall_arr,"l",lwd=2,col="blue",ylab="velocity profile",xlab="distance from centre [m]") |
59 | 81 | |
60 | 82 | dev.off() |
61 | 83 | |
62 | 84 | |
85 | + | |
63 | 86 | extension<-cbind(y_plus,wall_arr) |
64 | 87 | |
65 | 88 | new_sol<-rbind(solution[1:end_sol-1, ],extension) |
@@ -75,4 +98,119 @@ | ||
75 | 98 | fn <- paste("layer_thickness",layer_thickness,".txt",sep="") |
76 | 99 | write.table(new_sol,fn,row.names=FALSE) |
77 | 100 | |
101 | + | |
102 | +######################################################################### | |
103 | +######################################################################### | |
104 | +######################################################################### | |
105 | +######################################################################### | |
106 | +######################################################################### | |
107 | +######################################################################### | |
108 | + | |
109 | + | |
110 | + | |
111 | + | |
112 | +# Now I try doing the same for the concentration. I have to use the same kind of correction | |
113 | +# close to the wall. | |
114 | + | |
115 | +solution2<-read.table("bound-conc.txt",header=TRUE,nrow=20000) | |
116 | +solution2<-as.matrix(solution2) | |
117 | + | |
118 | +# now I re-define the solution | |
119 | + | |
120 | + | |
121 | +#y_plus<-n_viscous | |
122 | + | |
123 | +#norm_factor<-wall_fun() | |
124 | + | |
125 | +#zero<-which(solution2[ ,2]==0) | |
126 | +#zero<-as.vector(zero) | |
127 | +#zero<-zero[1] #probably I can skip all this and keep | |
128 | + # the previous definition of end_sol (which I decreased by 1 anyway ) these complications arise since the velocity is defined up to the wall (though it it wrong in the layer) whereas the concentration is not defined (so it is zero) in the layer; therefore I have to pick up the right value [last non-zero value] for the concentration othrwise the union with the analytical prolongment gets screwed up | |
129 | +#end_sol<-zero-1 | |
130 | + | |
131 | + | |
132 | +solution2<-solution2[1:end_sol, ] # numerical solution up to the wall | |
133 | + # where it is still non-zero and it has to be corrected | |
134 | + | |
135 | + | |
136 | + | |
137 | +rm(y_plus) | |
138 | + | |
139 | +y_plus<-seq(n_viscous,0,length=15000) | |
140 | + | |
141 | +wall_arr<-wall_fun()/norm_factor*solution2[end_sol,2] | |
142 | + | |
143 | + | |
144 | + | |
145 | +y_plus<-y_plus*viscous_length | |
146 | +y_plus<-sort(y_plus,decreasing=FALSE)+solution2[end_sol,1] | |
147 | + | |
148 | + | |
149 | +extension2<-cbind(y_plus,wall_arr) | |
150 | + | |
151 | +# the following is the new solution for the concentration up to the wall | |
152 | +new_sol2<-rbind(solution2[1:end_sol-1, ],extension2) | |
153 | + | |
154 | +pdf("new_solution_concentration.pdf") | |
155 | +plot(new_sol2[ ,1] ,new_sol2[ ,2],"l",lwd=2,col="blue",ylab="concentration profile",xlab="distance from centre [m]") | |
156 | +dev.off() | |
157 | + | |
158 | +# now I want to start working out the integrals providing the incoming/outcoming flux along z. I divide the job: part outside the layer and inside the layer | |
159 | + | |
160 | +rho_v_no_layer<-solution[ ,2]*solution2[ ,2] | |
161 | + | |
162 | +pdf("rho_v_outside_layer.pdf") | |
163 | +plot(solution[ ,1] ,rho_v_no_layer,"l",lwd=2,col="blue",ylab="rho*v",xlab="distance from centre [m]") | |
164 | +dev.off() | |
165 | + | |
166 | + # Now I have to multiply times 2*pi*r to take the radial integral | |
167 | + | |
168 | +rho_v_no_layer<-rho_v_no_layer*2*pi*solution[ ,1] | |
169 | + | |
170 | +pdf("rho_v_outside_layer*2pi*r.pdf") | |
171 | +plot(solution[ ,1] ,rho_v_no_layer,"l",lwd=2,col="blue",ylab="rho*v times 2pi*r",xlab="distance from centre [m]") | |
172 | +dev.off() | |
173 | + | |
174 | + | |
175 | +flux_no_layer<-def_integral(rho_v_no_layer,delta) | |
176 | +print("the concentration flux outside the layer is") | |
177 | +print(flux_no_layer) | |
178 | + | |
179 | + | |
180 | +# Now I need to work out the same thing with the layer. | |
181 | +###################################### | |
182 | +###################################### | |
183 | +###################################### | |
184 | +###################################### | |
185 | + | |
186 | + | |
187 | +rho_v_layer<-extension[ ,2]*extension2[ ,2] | |
188 | + | |
189 | + | |
190 | + | |
191 | +pdf("rho_v_layer.pdf") | |
192 | +plot(extension[ ,1] ,rho_v_layer,"l",lwd=2,col="blue",ylab="rho*v_layer",xlab="distance from centre [m]") | |
193 | +dev.off() | |
194 | + | |
195 | +print("ok here1") | |
196 | + | |
197 | + # Now I have to multiply times 2*pi*r to take the radial integral | |
198 | + | |
199 | +rho_v_layer<-rho_v_layer*2*pi*extension[ ,1] | |
200 | + | |
201 | +pdf("rho_v_outside_layer*2pi*r.pdf") | |
202 | +plot(extension[ ,1] ,rho_v_layer,"l",lwd=2,col="blue",ylab="rho*v_layer times 2pi*r",xlab="distance from centre [m]") | |
203 | +dev.off() | |
204 | + | |
205 | +# Now I redefine the parameter delta I need for the integration | |
206 | + | |
207 | +delta<-abs(extension[200,1]-extension[201,1]) | |
208 | + | |
209 | +flux_no_layer<-def_integral(rho_v_layer,delta) | |
210 | +print("the concentration flux outside the layer is") | |
211 | +print(flux_no_layer) | |
212 | + | |
213 | + | |
214 | + | |
215 | + | |
78 | 216 | print("So far so good") |
\ No newline at end of file |