Apsim Next Gen can be used to do your normal functions as you would from the full version.
Copy the path to the Models.exe executable. If installed for all users, this is located at:
"C:\Program Files\APSIM<Version-number>\bin\Models.exe"
replace <version-number> with your current version number.
Use:
"C:\Program Files\APSIM<Version-number>\bin\Models.exe" --apply <configFileName.txt>
Note: Above command can only be used when load is the first command in the configFile.
or use:
"C:\Program Files\APSIM<Version-number>\bin\Models.exe" --apply <configFileName.txt>
Models
instead of typing the full file path to the Models.exe.A config file is simply a text file with a simple command on each line.
save C:\TestSims\wheatTest.apsimx
load C:\TestSims\wheatTest.apsimx
add [ParentNodeName] childNodeName
add [ParentNodeName] childNodeName Name
add [ParentNodeName] exampleApsimFile.apsimx;[nodeName]
add [ParentNodeName] exampleApsimFile.apsimx;[nodeName] Name
delete [ParentNodeName].childNodeName
copy [NodeName] [AnotherNodesName]
copy [NodeName] [AnotherNodesName] Name
duplicate [NodeName].ChildNodeName.ChildNodeName NewName
[Weather].FileName=Dalby.met
#
or /
# Makes a new apsimx file and builds it up to something that will run
# Dalby.met needs to be in C:\TestSims\
load C:\TestSims\minimalSim.apsimx
# Add various nodes to the Simulations node.
add [Simulations] Simulation
add [Simulations] Experiment
add [Simulation] Summary
add [Simulation] Clock
add [Simulation] Weather
# Change data in various nodes.
[Weather].FileName=Dalby.met
[Clock].Start=1900/01/01
[Clock].End=1900/01/31
# Makes a copy of the simulation named Simulation and moves it to the Experiment node named Experiment.
copy [Simulation] [Experiment]
# Duplicate the simulation in the experiment
duplicate [Experiment].Simulation
# Deletes the original Simulation.
delete [Simulations].Simulation
# Saves the Simulation to new file.
save C:\TestSims\newMinimalSim.apsimx
# Runs the simulation.
run
--log
switch.error
.Models.exe example.apsimx --log error
--in-memory-db
switch.Models.exe example.apsimx --in-memory-db
Models.exe --apply config-file.txt --in-memory-db
Models.exe example.apsimx --apply config-file.txt --in-memory-db
--apply
switch can be used in conjunction with the --batch
switch.An example where this would be useful is when you want to change the soil and weather for each individual APSIM file and you have 10s to 100s to 1000s of APSIM files.
To do this you will need two specific files along with any APSIM files you want to change, these files are:
A config file containing ‘placeholders’
$weather-file-name
.load BaseCl.apsimx
[Soil]=SoilLibrary.apsimx;[$soil-name]
[Weather].FileName=$weather-file-name
[SimulationExp].Name=$sim-name
run
A batch file, this is a csv file with headers that match the placeholders (minus the $ symbols)
soil-name | weather-file-name | sim-name |
---|---|---|
Ahiaruhe_1a1 | 16864.met | Sim0001 |
Ahuriri_7a1 | 19479.met | Sim0002 |
Ailsa_5a1 | 19479.met | Sim0003 |
To run this we would run something like: "C:\Program Files\APSIM<your version number>\bin\Models.exe" --apply config-file-name.txt --batch batch-file-name.csv
The playlist model can be used to only run specific simulation models in a file.
To do this you can add a playlist model to the Simulations
model and add the names of the simulations or by using an expression in the provided text field.
To run a single file use a command like:
Models.exe my_sim_name.apsimx --playlist playlist_name
The Playlist’s text property can be changed dynamically using the --apply
switch. This allows users to selectively run specific Simulation
’s in an apsimx file.
Here is an example config file (commands.txt) that will run just Simulation named Simulation1 in an apsimx file (example.apsimx) that has two Simulation one named Simulation and another named Simulation1:
load example.apsimx
add [Simulations] Playlist
[Playlist].Text="Simulation1"
save sim1_example.apsimx
load sim1_example.apsimx
run
You’d run this with the command:
Models.exe --apply commands.txt --playlist playlist
Additional details are included below on its usage:
Enter a list of names of simulations that you want to run. Case insensitive.
A wildcard * can be used to represent any number of characters. A wildcard # can be used to represent any single character.
Simulations and Experiments can also be added to this playlist by right-clicking on them in the GUI.
Examples:
Sim1, Sim2, Sim3 - Runs simulations with exactly these names
[Sim1, Sim2, Sim3] - Also allows [ ] around the entry
Sim1 - Entries can be entered over multiple lines Sim2
Sim# - Runs simulations like Sim1, SimA, Simm, but will not run Sim or Sim11
Sim* - Runs simulations that start with Sim
*Sim - Runs simulations that end with Sim
*Sim* - Runs simulations with Sim anywhere in the name