Download presentation
Presentation is loading. Please wait.
Published byDaniela Higgins Modified over 9 years ago
1
Workshop U.S. Nuclear Regulatory Commission Rockville, Maryland Pacific Northwest National Laboratory November 15-17, 2005 Linking a Completely Stirred Tank Reactor (CSTR) to FRAMES-2
2
2 Completely Stirred Tank Reactor Outflow Water Flux (Q) Outflow Contaminant Concentration (C 2 ) Inflow Water Flux (Q) Inflow Contaminant Concentration (Co) Initial Concentration at t=0, Ci Control Volume Concentration (C 2 ) Soil
3
3 Where C 2 and C 1 = outflow concentrations at t 2 and t 1, respectively t2 and t1 = time C o = Inflow concentration R f = Retardation Factor λ = First-order degradation/decay rate V T = Total Volume (soil, water, air) Θ = moisture content Q = Inflow and Outflow rates Β d = Bulk density K d = Instantaneous Partitioning Distribution Coefficient
4
4 Derivations here Need to PDF Derivations and place them here
5
Directly Linking an Illustrative FORTRAN 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
6
Workshop U.S. Nuclear Regulatory Commission Rockville, Maryland Pacific Northwest National Laboratory November 15-17, 2005 Front End Linkage
7
7 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
8
8 Front-End Linkage 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,sim ulation,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)
9
9 Front-End Linkage (cont.) 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];
10
10 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,"CSTROut put",1)
11
Workshop U.S. Nuclear Regulatory Commission Rockville, Maryland Pacific Northwest National Laboratory November 15-17, 2005 Replace the FORTRAN Write Statement with a FRAMES-2 API Function Call
12
12 FORTRAN Write Statement: WRITE(21,FMT='(3E10.3)') t, c, Q*c Time Replace the FORTRAN Write Statement with a FRAMES-2 API Function Call for Time (t), Concentration (c), and Flux (Q*c) Concentration Desired Output 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.
13
13 CSTROutput DICtionary
14
14 Note: Dimension of 2 DIC: CSTROutput Variable: Conc Units: “mg/L” Indices: Chemical Name Time Note: “Real”
15
FRAMES-2 API Function Call Documentation
18
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 = pidpid = pidpid = pid dataset = OutputDataSetdataset = OutputDataSetdataset = OutputDataSet variable = “Time”variable = “Conc”variable = “Flux” unit = “yr”unit = “mg/L”unit = “g/yr” index1 = chemindex1 = chem index1 = chem index2 = TimeIdxindex2 = TimeIdx index2 = TimeIdx value = tvalue = 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)
19
Workshop U.S. Nuclear Regulatory Commission Rockville, Maryland Pacific Northwest National Laboratory November 15-17, 2005 Replace a FORTRAN Read Statement with a FRAMES-2 API Function Call for Total Concentration (Ct)
20
20 Original FORTRAN Read Statement: READ(20,FMT='(f8.3)')Ct Example Problem Read the Initial Total Concentration (Ct) in g/cm 3 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).
21
Note: Dimension of 1 Note: “Real” DIC: CSTRInput Variable: Ct Index: Chemical Name Units: “g/cm 3 ”
22
FRAMES-2 API Function Call Documentation
25
25 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/cm 3 The FRAMES-2 API Function Calls would be DataSetReadReal1: DataSetReadReal1(pid, dataset, variable, unit, index1) wherepid = 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)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.