📄 conf.f
字号:
* Copyright c 1998-2002 The Board of Trustees of the University of Illinois
* All rights reserved.
* Developed by: Large Scale Systems Research Laboratory
* Professor Richard Braatz, Director* Department of Chemical Engineering* University of Illinois
* http://brahms.scs.uiuc.edu
* * Permission hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal with the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimers.
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimers in the documentation and/or other materials
* provided with the distribution.
* 3. Neither the names of Large Scale Research Systems Laboratory,
* University of Illinois, nor the names of its contributors may
* be used to endorse or promote products derived from this
* Software without specific prior written permission.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* conf.f
*
* This program calculates the parameter covariance matrix and
* the variance for each growth and nucleation kinetic
* parameter (g, kg, b, and kb).
*
* This program reads the growth and nucleation
* kinetic parameters (g, kg, b, and kb), concentration, and
* moments data from data files.
*
*
* Nset=the number of the data files
*
* Date: August 8, 1998
* Authors: Serena H. Chung and Richard D. Braatz
* Department of Chemical Engineering
* University of Illinois at Urbana-Champaign
* Modified:March 6, 2000
* By: David L. Ma and Richard D. Braatz
*
* Modifications were to replace the use of transmittance
* measurements with moment measurements.
*
*
*
use MSIMSL
* PROGRAM MAIN
INTEGER NSTEP, NEQ, MXPARM, NTHETA, NU,Nsets
INTEGER npos1, npos2, MSTEP, Cinter, Minter
PARAMETER (NSTEP=161,NEQ=33,MXPARM=50,NTHETA=4, NU=6)
PARAMETER (Nsets=1, npos1=12, npos2=8, MSTEP=5)
PARAMETER (Cinter=1, Minter=30)
INTEGER I, J, K, M, N,Iteration, I1, L
INTEGER Norder, LDA, LDB, IPATH
PARAMETER(Norder=3, LDA=3, LDB=3,IPATH=1)
REAL*8 T, Y(NEQ)
REAL*8 F(NU*(NSTEP-1)*Nsets, NTHETA)
REAL*8 FTVF(NTHETA, NTHETA)
REAL*8 inv_FTVF(NTHETA,NTHETA)
REAL*8 FTV(NTHETA,NU*(NSTEP-1)*Nsets)
REAL*8 delt, tfinal, Msolv
REAL*8 mu00
REAL*8 cell_length, kv, ka, densityc, densitys
REAL*8 r0, alpha, g, kg, b, kb
REAL*8 moment0(NSTEP), moment1(NSTEP), moment2(NSTEP)
REAL*8 moment3(NSTEP), moment4(NSTEP)
REAL*8 time (NSTEP), concentration(NSTEP), seed_moment1(NSTEP)
REAL*8 seed_moment2(NSTEP), seed_moment3(NSTEP)
REAL*8 temperature(NSTEP), relsatn(NSTEP)
REAL*8 Temp, Csat, detFTVF
REAL*8 derivtheta(NSTEP,NU,NTHETA)
REAL*8 ConcData(NSTEP-1), Mu0Data(MSTEP), Mu1Data(MSTEP)
REAL*8 Mu2Data(MSTEP), Mu3Data(MSTEP), Mu4Data(MSTEP)
REAL*8 conc_variance, mu0_variance, mu1_variance
REAL*8 mu3_variance, mu4_variance, mu2_variance
REAL*8 chi_squared
REAL*8 g_interval, lnkg_interval, b_interval, lnkb_interval
REAL*8 AA(3,3), BB(3), gamma1(3), lmin, lmax
REAL*8 mass_seed, mean_seed, width
CHARACTER*60 file_concen, file_mu
*lsodes' parameters
INTEGER itol, iopt, itask, istate, mf
INTEGER lrw, liw, iwork(1000)
REAL*8 rtol, atol, rwork(5800)
EXTERNAL FCN, FCNJ
COMMON /GROWTH_DATA/kg, g
COMMON /BIRTH_DATA/kb, b
COMMON /EXP_DATA/r0, alpha, mu00
COMMON Iteration
file_concen='concen_data'
file_mu='mu_data'
conc_variance=0.0D0
mu0_variance=0.0D0
mu1_variance=0.0D0
mu2_variance=0.0D0
mu3_variance=0.0D0
mu4_variance=0.0D0
OPEN(UNIT=90, FILE='param.dat', FORM='FORMATTED',
& ACCESS='SEQUENTIAL', STATUS='UNKNOWN')
READ(90,*)g
READ(90,*)kg
READ(90,*)b
READ(90,*)kb
kg=DEXP(kg)
kb=DEXP(kb)
print*, "running"
DO 787 Iteration = 1, Nsets
*Simulation parameters
* controller time step in minutes
delt = 1.0D0
* final time in minutes
tfinal = DFLOAT(NSTEP)*delt
*Parameters for experimental set-up
* cell length for spectrophotometer in millimeter
* This was modified from that in Miller's thesis because
* his value (2.0) did not agree with his simulation results
cell_length=1.77D0
* mass of solvent in grams, converted from 2000 gallons
Msolv=7.57D6
* volume shape factor (Appendix C in Miller)
kv=1.0D0
* area shape factor (Appendix C in Miller)
ka=6.0D0
* heat transfer coefficient multiplied by surface area
* in calorie/minute/degree C
* density of solvent in g/cm^3 (solvent is water)
densitys=1.0D0
* density of crystal in g/cm^3 (Appendix C in Miller)
densityc=2.11D0
* seed size at nucleation
r0=0.0D0
* crystal density*volume shape factor,
* in gram crystal/micron^3/particle
* (alpha*L^3=mass of particle)
alpha=kv*densityc*(1.0D-4)**3
* Total mass of seed crystals (grams)
mass_seed = 230.0D0
* Mean size of the seed crystals (microns)
mean_seed = 196.0D0
* Percent width of the initial seed distribution
width = 6.12D0
*Growth and nucleation kinetic parameters
* (dimensionaless)
* g = 0.12889594028434D+01
* g = 0.13151365743328D+01
* g = 0.13125608981096D+01
* g = 0.12912359265617D+01
* g = 0.12993596644840D+01
* (mirons/minute)
* kg = DEXP(0.87458112413202D+01)
* kg = DEXP(0.88354817511395D+01)
* kg = DEXP(0.88246805512230D+01)
* kg = DEXP(0.87309813411979D+01)
* kg = DEXP(0.87620506647544D+01)
* (dimensionless)
* b = 0.17519140794580D+01
* b = 0.17762965268414D+01
* b = 0.17704343279926D+01
* b = 0.17465821622552D+01
* b = 0.17860382260529D+01
* (number of particles/cm^3/minute)
* (the units have been corrected from that reported in
* Table 3.1 in Miller)
* kb = DEXP(0.17048465188505D+02)
* kb = DEXP(0.17137238240957D+02)
* kb = DEXP(0.17106281255156D+02)
* kb = DEXP(0.17005247110939D+02)
* kb = DEXP(0.17179861650138D+02)
*Initial conditions
* initial concentration, g/g solvent
concentration(1) = 0.493D0
*
* The initial moments were computed using the following
* population density function:
*
* f_0(L)= aL^2 + b*L + c
*
* The distribution function is assumed to be symmetrical
* with the peak at L_bar. The function is equal to zero
* at L=L_bar-w/2 and L=L_bar+w/2, where w is the width
* paramter. In the program THETA_(Ntemp1+1) is the total
* seed, THETA(Ntemp1+2) is L_bar, and THETA_T(Ntemp1+3)
* is the width. Given the total mass, L_bar, and width w,
* the coefficient a, b, and c can be calcuted from the
* following system of equlations. Let
*
* lmin = L_bar - w/2
* lmax = L_bar + w/2
* mass = total seed mass
*
* Then
*
* (lmax^6-lmin^6)/6 a + (lmax^5-lmin^5)/5 b + (lmax^4-lmin^4)/4 c =
* mass/(mass_solvent*crystal_density)
*
* lmax^2 a + lmax b + c = 0
* lmin^2 a + lmax b + c = 0
*
* Note: In the implementation, the first equation is scaled.
*
lmin = mean_seed-width*(1.0D-2)*mean_seed
lmax = mean_seed+width*(1.0D-2)*mean_seed
AA(1,1) = (lmax**6-lmin**6)/6.0D0/1.0D12
AA(1,2) = (lmax**5-lmin**5)/5.0D0/1.0D12
AA(1,3) = (lmax**4-lmin**4)/4.0D0/1.0D12
AA(2,1) = lmin**2
AA(2,2) = lmin
AA(2,3) = 1.0D0
AA(3,1) = lmax**2
AA(3,2) = lmax
AA(3,3) = 1.0D0
BB(1)=mass_seed/
& (Msolv*densityc)*(1.0D4)**3/1.0D12
BB(2)=0.0D0
BB(3)=0.0D0
CALL DLSARG (Norder, AA, LDA, BB, IPATH, gamma1)
* initial zeroth moment, number of particle/g solvent
mu00 = gamma1(1)*(lmax**3-lmin**3)/3.0D0+
& gamma1(2)*(lmax**2-lmin**2)/2.0D0+
& gamma1(3)*(lmax-lmin)
moment0(1)= mu00
* initial first moment, micron/g solvent
moment1(1) = gamma1(1)*(lmax**4-lmin**4)/4.0D0+
& gamma1(2)*(lmax**3-lmin**3)/3.0D0+
& gamma1(3)*(lmax**2-lmin**2)/2.0D0
seed_moment1(1)=moment1(1)
* initia1 second moment, micron^2/g solvent
moment2(1) = gamma1(1)*(lmax**5-lmin**5)/5.0D0+
& gamma1(2)*(lmax**4-lmin**4)/4.0D0+
& gamma1(3)*(lmax**3-lmin**3)/3.0D0
seed_moment2(1)=moment2(1)
* initial third moment, micron^3/g solvent
moment3(1) = gamma1(1)*(lmax**6-lmin**6)/6.0D0+
& gamma1(2)*(lmax**5-lmin**5)/5.0D0+
& gamma1(3)*(lmax**4-lmin**4)/4.0D0
seed_moment3(1)=moment3(1)
* print*,moment3(1)*Msolv*densityc*(1.0e-12)
* print*,THETA_T(Ntemp1+1)
* initial fourth moment, micron^4/g solvent
moment4(1) = gamma1(1)*(lmax**7-lmin**7)/7.0D0+
& gamma1(2)*(lmax**6-lmin**6)/6.0D0+
& gamma1(3)*(lmax**5-lmin**5)/5.0D0
* initial relative supersaturation
relsatn(1)=(concentration(1)-Csat(Temp(0.0D0)))/
& Csat(Temp(0.0D0))
* Initial conditions for derivatives wrt to theta
DO 163 I = 1 , NU
DO 164 J = 1 , NTHETA
derivtheta(1,I,J)=0.0D0
164 CONTINUE
163 CONTINUE
* Read Data in files
I1=10+Iteration
DO J = 1,NSTEP-1
WRITE(file_concen(npos1:npos1+1), '(I2)') I1
file_concen = file_concen(1:npos1+1) // '.txt'
OPEN(UNIT=20, FILE=file_concen, FORM='FORMATTED',
& ACCESS='SEQUENTIAL', STATUS='OLD')
READ(20,*) ConcData(J)
ENDDO
CLOSE(UNIT=20)
DO J=1,MSTEP
WRITE(file_mu(npos2:npos2+1), '(I2)') I1
file_mu = file_mu(1:npos2+1) // '.txt'
OPEN(UNIT=20, FILE=file_mu, FORM='FORMATTED',
& ACCESS='SEQUENTIAL', STATUS='OLD')
READ(20,*) Mu0Data(J), Mu1Data(J), Mu2Data(J),
& Mu3Data(J), Mu4Data(J)
ENDDO
CLOSE(UNIT=20)
*Simulation parameters
*********************************************************
*
mf=222
itask=1
istate =1
iopt=0
lrw=3800
liw=200
rtol=1.0d-11
atol=1.0d-10
itol=1
******************************************************
*
time(1)=0.0D0
T=0.0D0
L=1
DO 1200 I=1,(NSTEP-1)
temperature(I)=Temp(T)
Y(1)=moment0(I)
Y(2)=moment1(I)
Y(3)=moment2(I)
Y(4)=moment3(I)
Y(5)=moment4(I)
Y(6)=concentration(I)
Y(7)=seed_moment1(I)
Y(8)=seed_moment2(I)
Y(9)=seed_moment3(I)
K = 10
DO 263 M = 1 , NU
DO 264 N = 1 , NTHETA
Y(K)=derivtheta(I,M,N)
K = K + 1
264 CONTINUE
263 CONTINUE
CALL lsodes ( FCN,NEQ,Y,T,T+Cinter,itol,rtol,
& atol,itask,istate,iopt,
& rwork,lrw,iwork,liw, FCNJ, mf )
moment0(I+1)=Y(1)
moment1(I+1)=Y(2)
moment2(I+1)=Y(3)
moment3(I+1)=Y(4)
moment4(I+1)=Y(5)
concentration(I+1)=Y(6)
seed_moment1(I+1)=Y(7)
seed_moment2(I+1)=Y(8)
seed_moment3(I+1)=Y(9)
relsatn(I+1)=(Y(6)-Csat(Temp(T)))/Csat(Temp(T))
time(I+1)=T
K = 10
DO 363 M = 1 , NU
DO 364 N = 1 , NTHETA
derivtheta(I+1,M,N)=Y(K)
F((NSTEP-1)*(Iteration-1)+Nu*(I-1)+M,N)=Y(k)
K = K + 1
364 CONTINUE
363 CONTINUE
conc_variance=conc_variance+
& (ConcData(I)-concentration(I+1))**2.0D0
IF ((int(I*Cinter/Minter/L).EQ.1) .AND. (L .LE. MSTEP)) THEN
mu0_variance=mu0_variance+
& (Mu0Data(L)-moment0(I+1))**2.0D0
mu1_variance=mu1_variance+
& (Mu1Data(L)-moment1(I+1))**2.0D0
mu2_variance=mu2_variance+
& (Mu2Data(L)-moment2(I+1))**2.0D0
mu3_variance=mu3_variance+
& (Mu3Data(L)-moment3(I+1))**2.0D0
mu4_variance=mu4_variance+
& (Mu4Data(L)-moment4(I+1))**2.0D0
L=L+1
END IF
1200 CONTINUE
787 CONTINUE
1 FORMAT(2(F13.6,3x))
2 FORMAT(I1)
3 FORMAT(2(E16.6,3x),2(F16.6,3x))
mu0_variance=mu0_variance/DFLOAT((NSTEP-1)*Nsets)
mu1_variance=mu1_variance/DFLOAT((NSTEP-1)*Nsets)
mu2_variance=mu2_variance/DFLOAT((NSTEP-1)*Nsets)
mu3_variance=mu3_variance/DFLOAT((NSTEP-1)*Nsets)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -