⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 confsun.f

📁 对工业生产过程结晶过程的一个仿真程序软件包
💻 F
📖 第 1 页 / 共 2 页
字号:
* 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 
* 	teh coefficient of variation for each  growth and nucleation 
*       kinetic parameter (g, kg, b, and kb).
*
*	This program reads the actual growth and nucleation 
*       kinetic parameters (g, kg, b, and kb), concentraion and 
*       transmittance data from data files.
*
*       The data files should be formatted in the following:
*
*                      actual_g         actual_Ln(kg)
*                      actual_b         actual_Ln(kb)
*                      concentration    transmittance
*
*       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
*
*
*




      PROGRAM MAIN

      INTEGER NSTEP, NEQ, MXPARM, NTHETA, NU,Nsets
      PARAMETER (NSTEP=161,NEQ=33,MXPARM=50,NTHETA=4, NU=6)
      PARAMETER (Nsets=1)
      INTEGER I, J, K, M, N,Iteration
      INTEGER Norder, LDA, LDB, IPATH
      PARAMETER(Norder=3, LDA=3, LDB=3,IPATH=1)
      REAL*8 T, Y(NEQ)
      REAL*8 F(2*(NSTEP-1)*Nsets, NTHETA)
      REAL*8 FTVF(NTHETA, NTHETA)
      REAL*8 inv_FTVF(NTHETA,NTHETA)
      REAL*8 FTV(NTHETA,2*(NSTEP-1)*Nsets)
      REAL*8 delt, tfinal, const1, Msolv
      REAL*8 mu00
      REAL*8 cell_length, kv, ka, densityc, densitys
      REAL*8 r0, alpha, g, kg, b, kb
*      REAL*8 weight_mean_size, cov, mass_ratio
      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 transmittance(NSTEP)
      REAL*8 temperature(NSTEP), relsatn(NSTEP)
      REAL*8 Temp, Csat, detFTVF
      REAL*8 derivtheta(NSTEP,NU,NTHETA)
      REAL*8 sigma_trans, sigma_conc
      REAL*8 actual_g, actual_ln_kg, actual_b, actual_ln_kb
      REAL real_time(NSTEP), real_temperature(NSTEP)
      REAL real_concentration(NSTEP)
      REAL real_moment0(NSTEP), real_moment1(NSTEP), real_moment2(NSTEP)
      REAL real_moment3(NSTEP), real_transmittance(NSTEP)
      REAL real_satn(NSTEP)
      REAL*8 ConcData(NSTEP-1), TransData(NSTEP-1)
      REAL*8 derivIg(NSTEP), derivconcg(NSTEP)
      REAL*8 derivIlnkg(NSTEP),derivconclnkg(NSTEP)
      REAL*8 derivIb(NSTEP), derivIlnkb(NSTEP)
      REAL*8 derivconcb(NSTEP), derivconclnkb(NSTEP)
      REAL*8 conc_variance, trans_variance
      REAL*8 chi_squared
      REAL*8 g_interval, lnkg_interval, b_interval, lnkb_interval
      REAL*8 AA(3,3), BB(3), gamma(3), lmin, lmax
      REAL*8 mass_seed, mean_seed, width

      REAL real_derivIg(NSTEP), real_derivconcg(NSTEP)
      REAL real_derivIlnkg(NSTEP),real_derivconclnkg(NSTEP)
      REAL real_derivIb(NSTEP), real_derivIlnkb(NSTEP)
      REAL real_derivconcb(NSTEP), real_derivconclnkb(NSTEP)
      REAL real_derivtheta(NSTEP,NU,NTHETA)


*lsodes' parameters
      
      INTEGER itol, iopt, itask, istate, mf
      INTEGER lrw, liw, iwork(1000)
      REAL*8  rtol, atol, rwork(5800)    

      EXTERNAL FCN, FCNJ, DIVPAG, DEVCSF, DLINRG, DLSARG

      COMMON /GROWTH_DATA/kg, g
      COMMON /BIRTH_DATA/kb, b 
      COMMON /EXP_DATA/r0, alpha, mu00
      COMMON Iteration

      conc_variance=0.0D0
      trans_variance=0.0D0

      DO 787 Iteration = 1, Nsets

*Simulation parameters
*     controller time step in minutes
      delt = 1.0D0
*     final time in minutes
      tfinal = DFLOAT(NSTEP)*delt
*     noise for transmittance measurement
      sigma_trans=0.009D0
*     noise for concentration measurement
      sigma_conc=0.0005D0

*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, gamma)

*     initial zeroth moment, number of particle/g solvent
      mu00 = gamma(1)*(lmax**3-lmin**3)/3.0D0+
     &	     gamma(2)*(lmax**2-lmin**2)/2.0D0+
     &	     gamma(3)*(lmax-lmin)
      moment0(1)= mu00
*     initial first moment, micron/g solvent
      moment1(1) = gamma(1)*(lmax**4-lmin**4)/4.0D0+
     &		   gamma(2)*(lmax**3-lmin**3)/3.0D0+
     &	           gamma(3)*(lmax**2-lmin**2)/2.0D0
      seed_moment1(1)=moment1(1)
*     initia1 second moment, micron^2/g solvent
      moment2(1) = gamma(1)*(lmax**5-lmin**5)/5.0D0+
     &		   gamma(2)*(lmax**4-lmin**4)/4.0D0+
     &	           gamma(3)*(lmax**3-lmin**3)/3.0D0
      seed_moment2(1)=moment2(1)
*     initial third moment, micron^3/g solvent
      moment3(1) = gamma(1)*(lmax**6-lmin**6)/6.0D0+
     &		   gamma(2)*(lmax**5-lmin**5)/5.0D0+
     &	           gamma(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) = gamma(1)*(lmax**7-lmin**7)/7.0D0+
     &		   gamma(2)*(lmax**6-lmin**6)/6.0D0+
     &	           gamma(3)*(lmax**5-lmin**5)/5.0D0

*     initial relative supersaturation
      relsatn(1)=(concentration(1)-Csat(Temp(0.0D0)))/
     &     Csat(Temp(0.0D0))
*     initial transmittance measurement
      transmittance(1)=DEXP(-ka/2D0*cell_length/10.D0*moment2(1)*
     &     (densitys*(1.D-4)**2.D0))

*     initial d I/dg
      derivIg(1)=0.0D0
*     initial d conc/dg
      derivconcg(1) = 0.0D0
*     initial d I/ d lnkg
      derivIlnkg(1)=0.0D0
*     initial d conc/d lnkg
      derivconclnkg(1) = 0.0D0

*     initial d I/db
      derivIb(1)=0.0D0
*     initial d conc/db
      derivconcb(1) = 0.0D0
*     initial d I/ d lnkb
      derivIlnkb(1)=0.0D0
*     initial d conc/d lnkb
      derivconclnkb(1) = 0.0D0

*     Other 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(55+Iteration,*) actual_g, actual_ln_kg
      READ(55+Iteration,*) actual_b, actual_ln_kb

*    Read in data from file
      DO 121 I = 1,(NSTEP-1)
        READ(55+Iteration,*) ConcData(I), TransData(I)
121   CONTINUE
      CLOSE(55+Iteration)



*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    

        
      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+1,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))
         transmittance(I+1)=DEXP(-ka/2.0D0*cell_length/10.0D0*
     &        moment2(I+1)*(densitys*(1.0D-4)**2.D0))
         time(I+1)=T
         K = 10
         DO 363 M = 1 , NU
            DO 364 N = 1 , NTHETA
               derivtheta(I+1,M,N)=Y(K)
	       K = K + 1
364         CONTINUE
363      CONTINUE

         const1=ka/2.0D0*cell_length/10.0D0*
     &			densitys*(1.0D-4)**(2.D0)

         derivIg(I+1)=-const1*DEXP(-const1*Y(3))*Y(18)
	 derivIlnkg(I+1)=-const1*DEXP(-const1*Y(3))*Y(19)
         derivIb(I+1)=-const1*DEXP(-const1*Y(3))*Y(20)
         derivIlnkb(I+1)=-const1*DEXP(-const1*Y(3))*Y(21)        
         derivconcg(I+1)=Y(30)
	 derivconclnkg(I+1)=Y(31)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -