Workshop U.S. Nuclear Regulatory Commission Rockville, Maryland Pacific Northwest National...

25
Workshop U.S. Nuclear Regulatory Commission Rockville, Maryland Pacific Northwest National Laboratory November 15-17, 2005 Linking a Completely Stirred Tan Reactor (CSTR) to FRAMES-2

Transcript of Workshop U.S. Nuclear Regulatory Commission Rockville, Maryland Pacific Northwest National...

WorkshopU.S. Nuclear Regulatory Commission

Rockville, Maryland

Pacific Northwest National LaboratoryNovember 15-17, 2005

Linking a Completely Stirred TankReactor (CSTR) to FRAMES-2

2

Completely Stirred Tank ReactorCompletely Stirred Tank ReactorCompletely Stirred Tank ReactorCompletely Stirred Tank Reactor

Outflow Water Flux (Q)Outflow Contaminant Concentration (C2)

Inflow Water Flux (Q)Inflow Contaminant Concentration (Co)

Initial Concentration at t=0, Ci

Control VolumeConcentration (C2)

Soil

3

Where

C2 and C1 = outflow concentrations at t2 and t1, respectivelyt2 and t1 = timeCo = Inflow concentrationRf = Retardation Factorλ = First-order degradation/decay rateVT = Total Volume (soil, water, air)Θ = moisture contentQ = Inflow and Outflow ratesΒd = Bulk densityKd = Instantaneous Partitioning Distribution Coefficient

4

Derivations hereDerivations hereDerivations hereDerivations here

Need to PDF Derivations and place them here

Directly Linking an IllustrativeDirectly Linking an IllustrativeFORTRAN Model to FRAMES-2FORTRAN Model to FRAMES-2Directly Linking an IllustrativeDirectly Linking an IllustrativeFORTRAN Model to FRAMES-2FORTRAN 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

WorkshopU.S. Nuclear Regulatory Commission

Rockville, Maryland

Pacific Northwest National LaboratoryNovember 15-17, 2005

Front End LinkageFront End Linkage

7

Front-end linkageFront-end linkageFront-end linkageFront-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

Front-End LinkageFront-End LinkageFront-End LinkageFront-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,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)

9

Front-End Linkage (cont.)Front-End Linkage (cont.)Front-End Linkage (cont.)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

Define pid and I/O FilesDefine pid and I/O FilesDefine pid and I/O FilesDefine 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)

WorkshopU.S. Nuclear Regulatory Commission

Rockville, Maryland

Pacific Northwest National LaboratoryNovember 15-17, 2005

Replace the FORTRAN Write StatementReplace the FORTRAN Write Statementwith a FRAMES-2 API Function Callwith a FRAMES-2 API Function Call

12

FORTRAN Write Statement: WRITE(21,FMT='(3E10.3)') t, c, Q*c

Time

Replace the FORTRAN Write StatementReplace the FORTRAN Write Statementwith a FRAMES-2 API Function Call forwith a FRAMES-2 API Function Call for

Time (t), Concentration (c), and Flux (Q*c)Time (t), Concentration (c), and Flux (Q*c)

Replace the FORTRAN Write StatementReplace the FORTRAN Write Statementwith a FRAMES-2 API Function Call forwith a FRAMES-2 API Function Call for

Time (t), Concentration (c), and Flux (Q*c)Time (t), Concentration (c), and Flux (Q*c)

Co

nce

ntr

atio

n 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

CSTROutputDICtionary

14

Note:Dimension

of 2

DIC: CSTROutputVariable: Conc

Units:“mg/L”

Indices: Chemical Name Time

Note:“Real”

FRAMES-2 API Function Call Documentation

FRAMES-2 API Function Call Documentation

FRAMES-2 API Function Call Documentation

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)

WorkshopU.S. Nuclear Regulatory Commission

Rockville, Maryland

Pacific Northwest National LaboratoryNovember 15-17, 2005

Replace a FORTRAN Read Statement Replace a FORTRAN Read Statement with a FRAMES-2 API Function Call with a FRAMES-2 API Function Call

for Total Concentration (Ct)for Total Concentration (Ct)

20

Original FORTRAN Read Statement: READ(20,FMT='(f8.3)')Ct

Example ProblemExample ProblemRead the Initial Total Concentration Read the Initial Total Concentration

(Ct) in g/cm(Ct) in g/cm33

Example ProblemExample ProblemRead the Initial Total Concentration Read the Initial Total Concentration

(Ct) in g/cm(Ct) in g/cm33

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).

Note: Dimension

of 1

Note:“Real”

DIC: CSTRInputVariable: Ct

Index: Chemical Name

Units:“g/cm3”

FRAMES-2 API Function Call Documentation

FRAMES-2 API Function Call Documentation

FRAMES-2 API Function Call Documentation

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/cm3

The FRAMES-2 API Function Calls would be DataSetReadReal1:DataSetReadReal1(pid, dataset, variable, unit, index1)

where pid = piddataset = InputDataSetvariable = “Ct” unit = “g/cm^3”index1 = chem

Producing a FRAMES-2 API Read call of Ct=DataSetReadReal1(pid, InputDataSet, "Ct", "g/cm^3", chem)