DSL Root Element sim{}
A basic simulation is the standard method to setup and run a model. The root DSL element is sim, and a sim file may contain instances of six sub-elements, as shown the following table.
//create the simulation object
sim(name:"CSMLite Basic Simulation for Workshop") {
//add sub-elements...
}
Element sim{}
Specification
Name |
sim - Specifies a basic model simulation |
Property | Description | Type | Required |
name | Name of the simulation | String | Root element for basic simulation |
Sub-Elements | Description | Type | Default | Occurrences |
build | Build the model | - | - | One, optional |
model{} | Define the model | - | - | One, required |
resource | List resources for the model | - | - | Zero or many |
outputstrategy | Manage storage of output | - | - | Zero or one |
output | Capture and store output field values | - | - | Zero or one |
summary | Apply ad hoc statistics | - | - | Zero to many |
efficiency | Quantify the prediction performance of the model | - | - | Zero to many |
analysis{} | Analyze by plotting or graphing | - | - | Zero or one |
Example
/*
* EF Carson simulation.
*/
sim(name:"Efcarson") {
build()
// define output strategy: output base dir and
// the scheme NUMBERED|SIMPLE|DATE
outputstrategy(dir:"$oms_prj/output", scheme:SIMPLE)
// model definition
model(classname:"model.PrmsDdJh") {
// parameter definition
parameter (file:"$oms_prj/data/efc_svntest.csv") {
inputFile "$oms_prj/data/data.csv"
outFile "out.csv"
sumFile "basinsum.csv"
out "summary.txt"
startTime "1980-10-01"
endTime "1986-09-30"
}
logging {
// "Ddsolrad" "INFO"
}
}
//model efficiency (optional)
efficiency(obs:"runoff[0]", sim:"basin_cfs", methods:NS+ABSDIF+TRMSE)
// compute some summary for runoff 'on-the-fly' (optional)
summary(time:"date", var:"basin_gwflow_cfs", moments:MEAN+MIN+MAX+LAG1,
period:YEARLY, file:"sum.txt")
output(time:"date", vars:"runoff[0], basin_cfs, basin_sroff_cfs,
basin_ssflow_cfs,basin_gwflow_cfs, basin_potet,basin_actet,",
fformat:"9.6f", file:"out1.csv")
analysis(title:"Simulation Output") {
timeseries(title:"Efc_Q", view: COMBINED ) {
x(file:"%last/out1.csv", column:"date")
y(file:"%last/out1.csv", column:"runoff[0]")
y(file:"%last/out1.csv", column:"basin_cfs")
}
timeseries(title:"Sim_Error", view: STACKED) {
x(file:"%last/out1.csv", column:"date")
calc(eq:"simulated - observed") {
simulated(file:"%last/out1.csv", column:"basin_cfs")
observed(file:"%last/out1.csv", column:"runoff[0]")
}
calc(eq:"simulated - observed", acc:true) {
simulated(file:"%last/out1.csv", column:"basin_cfs")
observed(file:"%last/out1.csv", column:"runoff[0]")
}
}
timeseries(title:"Components of Flow", view: COMBINED ) {
x(file:"%last/out1.csv", column:"date")
y(file:"%last/out1.csv", column:"basin_sroff_cfs")
y(file:"%last/out1.csv", column:"basin_ssflow_cfs")
y(file:"%last/out1.csv", column:"basin_gwflow_cfs")
}
timeseries(title:"Potet vs Actet", view: COMBINED ) {
x(file:"%last/out1.csv", column:"date")
y(file:"%last/out1.csv", column:"basin_potet")
y(file:"%last/out1.csv", column:"basin_actet")
}
}
}