250 likes | 497 Views
Linking a Completely Stirred Tank Reactor (CSTR) to FRAMES-2. Workshop U.S. Nuclear Regulatory Commission Rockville, Maryland Pacific Northwest National Laboratory November 15-17, 2005. Inflow Water Flux (Q) Inflow Contaminant Concentration (Co). Soil. Control Volume
E N D
Linking a Completely Stirred Tank Reactor (CSTR) to FRAMES-2 Workshop U.S. Nuclear Regulatory Commission Rockville, Maryland Pacific Northwest National Laboratory November 15-17, 2005
Inflow Water Flux (Q) Inflow Contaminant Concentration (Co) Soil Control Volume Concentration (C2) Initial Concentration at t=0, Ci Outflow Water Flux (Q) Outflow Contaminant Concentration (C2) Completely Stirred Tank Reactor 2
Where C2 and C1 = outflow concentrations at t2 and t1, respectively t2 and t1 = time Co = Inflow concentration Rf = Retardation Factor λ = First-order degradation/decay rate VT = Total Volume (soil, water, air) Θ = moisture content Q = Inflow and Outflow rates Βd = Bulk density Kd = Instantaneous Partitioning Distribution Coefficient 3
Derivations here • Need to PDF Derivations and place them here 4
Directly Linking an IllustrativeFORTRAN Model to FRAMES-2 Using FRAMES-2 API Function Calls 1. Link Model to FRAMES-2 2. Use FRAMES-2 Approach to Produce Data 3. Use FRAMES-2 Approach to Consume Data
Front End Linkage Workshop U.S. Nuclear Regulatory Commission Rockville, Maryland Pacific Northwest National Laboratory November 15-17, 2005
Front-end linkage • Purpose • Show the differences in versions of FORTRAN for getting commandline arguments • Show how FORTRAN, Java, C/C++ are all very similar • Show that only a few lines of code can get these arguments 7
Lahey FORTRAN Use “Module” Use F2ModuleDev GetCL reads Commandline into a character * variable GetCL(commandline) Internal read to read pieces of commandline read(commandline),path,simulation,module MS-Derived FORTRAN Compaq, Digital, Powerstation Use “Module” Use F2ModuleDev GetArg(1,path) path=trim(path)//char(0) GetArg(2,simulation) path=trim(path)//char(0) GetArg(3,module) path=trim(path)//char(0) Front-End Linkage 8
Java import FRAMES2API.F2ModuleDev Standard main provides arguments public static int main(String[] argv) path=argv[0]; simulation=argv[1]; module=argv[2] C/C++ #include “Developer\F2ModuleDevC.h” Standard main provides arguments void main(int arg,char **argv) path=argv[1]; simulation=argv[2]; module=argv[3]; Front-End Linkage (cont.) 9
Define pid and I/O Files • Define a Process IDentifier (pid) • function of path, simulation, moduleId, and is used in all subsequent calls to the API and can be thought of as a way to state who is making changes or reading datasets. • pid=OpenIO(path,simulation,moduleId) • Define the name and location of the input (CSTRInput) and output (CSTROutput) DICtionaries, cross-correlated to pid and moduleId • InputDataSet=IconGetUIDataSet(pid,moduleId,"CSTRInput",1) • OutputDataSet=IconGetOutputDataset(pid,moduleid,"CSTROutput",1) 10
Replace the FORTRAN Write Statement with a FRAMES-2 API Function Call Workshop U.S. Nuclear Regulatory Commission Rockville, Maryland Pacific Northwest National Laboratory November 15-17, 2005
Replace the FORTRAN Write Statementwith a FRAMES-2 API Function Call forTime (t), Concentration (c), and Flux (Q*c) Desired Output FORTRAN Write Statement: WRITE(21,FMT='(3E10.3)') t, c, Q*c Concentration Time Given: 1. You are familiar with or wrote the code. 2. You will define a system DICtionary, titled “CSTROutput”. The code internally denotes this file name as the variable OutputDataSet. 3. The code uses indices to track Chemical Names (e.g., 1 = Chemical #1) as “chem”, and Time as “TimeIdx”. 4. This model is a zero-dimension model. 5. The variables t and c are Real and have units of yr and mg/L, respectively. 12
CSTROutput DICtionary 13
Note: “Real” Note: Dimension of 2 Units: “mg/L” Indices: Chemical Name Time DIC: CSTROutput Variable: Conc 14
Summary of Known Information: 1. “t” for time, “c” for concentration, and Q*c for flux are Real (i.e., Floats). The names for t, c, and Q*c are Time, Conc, and Flux, respectively. 2. t has units of years, c has units of mg/L, and Q*c has units of g/yr. 3. t, c, and Q*c have two indices each: one Chemical Name, which is tracked in the model by the index “chem”, and one based on time, which is tracked in the model by the index “TimeIdx”. 4. OutputDataSet is the variable file name, storing the input file name of CSTROutput. The FRAMES-2 API Function Calls would be DataSetWriteReal2: DataSetWriteReal2(pid, dataset, variable, unit, index1, index2, value) Where pid = pid pid = pid pid = pid dataset = OutputDataSet dataset = OutputDataSet dataset = OutputDataSet variable = “Time” variable = “Conc” variable = “Flux” unit = “yr” unit = “mg/L” unit = “g/yr” index1 = chem index1 = chem index1 = chem index2 = TimeIdx index2 = TimeIdx index2 = TimeIdx value = t value = c value = Q*c Producing a FRAMES-2 API Write calls of call DataSetWriteReal2(pid, OutputDataSet, "Time", "yr", Chem, TimeIdx, t) call DataSetWriteReal2(pid, OutputDataSet, "Conc", "mg/L", Chem, TimeIdx, c) call DataSetWriteReal2(pid, OutputDataSet, “Flux", “g/yr", Chem, TimeIdx, Q*c)
Replace a FORTRAN Read Statement with a FRAMES-2 API Function Call for Total Concentration (Ct) Workshop U.S. Nuclear Regulatory Commission Rockville, Maryland Pacific Northwest National Laboratory November 15-17, 2005
Example ProblemRead the Initial Total Concentration (Ct) in g/cm3 Original FORTRAN Read Statement: READ(20,FMT='(f8.3)')Ct Given: 1. You are familiar with or wrote the code. 2. You have already created or will create an user-friendly input dataset, based on the DICtionary, titled “CSTRInput”. The code internally denotes this file name as the variable InputDataSet. 3. The code uses indices to track Chemical Names (e.g., 1 = Chemical #1, 2 = Chemical #2, etc.), and this index is labeled “chem”. 4. This model is a zero-dimension model. 5. The variable Ct is a Real (i.e., Float). 20
Note: Dimension of 1 Units: “g/cm3” Note: “Real” DIC: CSTRInput Variable: Ct Index: Chemical Name
Summary of Known Information: 1. You have already created or will create an user-friendly input dataset, based on the DICtionary, titled “CSTRInput”. The code internally denotes this file name as the variable “InputDataSet”. 2. The code uses indices to track Chemical Names (e.g., 1 = Chemical #1, 2 = Chemical #2, etc.), and this variable is labeled “chem”. 3. This model is a zero-dimension model. 4. The input concentration Ct variable is a Real (i.e., Float) with units of g/cm3 The FRAMES-2 API Function Calls would be DataSetReadReal1: DataSetReadReal1(pid, dataset, variable, unit, index1) where pid = pid dataset = InputDataSet variable = “Ct” unit = “g/cm^3” index1 = chem Producing a FRAMES-2 API Read call of Ct=DataSetReadReal1(pid, InputDataSet, "Ct", "g/cm^3", chem) 25