Skip to content

Commit

Permalink
Factoring out some models
Browse files Browse the repository at this point in the history
  • Loading branch information
Maginor committed Sep 5, 2024
1 parent 3d3719f commit a971f44
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 149 deletions.
10 changes: 5 additions & 5 deletions docs/gettingstarted/gettingstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ You can also download a zip archive of the repository from its github front page

### 2. Get the MobiView2 program.

For now we only support MobiView2 on Windows. It is technically possible to compile it on Linux, so if you need that, please contact us.
For now we only support MobiView2 on Windows. It is theoretically possible to compile it on Linux, so if you need that, please contact us.

Open ftp://mobiserver.niva.no/Mobius2 in a file explorer (not a web browser), then download the entire MobiView2 folder by copying it over to somewhere on your machine.

In your local copy, edit MobiView2/config.txt so that the "Mobius2 base path" field contains the location where you put Mobius2 repository, e.g. `"C:/Data/Mobius2"`.
In your local copy, edit MobiView2/config.txt so that the "Mobius2 base path" field contains the location where you put the Mobius2 repository, e.g. `"C:/Data/Mobius2"`.

You can now run MobiView2.exe. Click the ![Open](../img/toolbar/Open.png) open icon in the top left and select e.g. `"Mobius2/models/simplyq.txt"`, then `"Mobius2/models/data/simplyq_simple.dat"`. If the model loaded correctly you can now run it by clicking the ![Run](../img/toolbar/Run.png) runner icon in the MobiView2 toolbar. You can then select series to plot in the result and input series selections in the bottom right.
You can now run MobiView2.exe. Click the ![Open](../img/toolbar/Open.png) open icon in the top left and select e.g. `"Mobius2/models/simplyq.txt"`, then `"Mobius2/models/data/simplyq_simple.dat"`. If the model loaded correctly you can now run it by clicking the ![Run](../img/toolbar/Run.png) runner icon in the MobiView2 toolbar. You can then select the series to plot in the result and input series selections in the bottom right.

If you chose simplyq.txt, you are running [SimplyQ](../existingmodels/simply.html#simplyq), which is a simple hydrology model for predicting river discharge.
If you chose `simplyq.txt`, you are running [SimplyQ](../existingmodels/simply.html#simplyq), which is a simple hydrology model for predicting river discharge.

![MobiView2](../img/mobiview_gettingstarted.png)

Expand Down Expand Up @@ -74,4 +74,4 @@ The [Guide](../mobius2docs/guide.html) is a good place to start.

### Involve yourself with feedback to the developer team, or become a developer.

Please use the github issues tracker to report bugs. You can also contact us at `magnus.norling@niva.no`
Please use the [github issues tracker](https://github.com/NIVANorge/Mobius2/issues) to report bugs. You can also contact us at `magnus.norling@niva.no`
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Mobius2 also provides special support for transport along directed graphs and gr

## Authors and acknowledgement

The Mobius2 framework is developed by Magnus Dahler Norling for [The Norwegian Institute for Water Research](https://www.niva.no/en) (NIVA).
The Mobius2 framework is developed by Magnus Dahler Norling for [the Norwegian Institute for Water Research](https://www.niva.no/en) (NIVA).

Additional contributions:
Leah Jackson-Blake (Simply models, general testing), François Clayer (EasyLake model, general testing).
Expand Down
4 changes: 2 additions & 2 deletions models/modules/hbv_snow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ module("HBVSnow", version(1, 0, 0),
"""
This is an adaption of the snow module from HBV-Nordic (Sælthun 1995)

[NVE home page](https://www.nve.no/vann-og-vassdrag/vannets-kretslop/analysemetoder-og-modeller/hbv-modellen/)
[NVE home page](https://www.nve.no/vann-og-vassdrag/vannets-kretsloep/analysemetoder-og-modeller/hbv-modellen/)

[Model description](https://www.uio.no/studier/emner/matnat/geofag/nedlagte-emner/GEO4430/v06/undervisningsmateriale/HBVMOD.PDF)
[Model description](https://publikasjoner.nve.no/publication/1996/publication1996_07.pdf)

Authors: Magnus D. Norling
"""
Expand Down
7 changes: 5 additions & 2 deletions models/modules/nivafjord/basin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module("NIVAFjord basin", version(0, 0, 3),
area : property,
freeze_temp : property,
sw : property,
ice_ind : loc,
vert : connection,
sw_vert : connection,
sw_sed : loc,
Expand Down Expand Up @@ -85,6 +86,7 @@ Authors: Magnus D. Norling

par_group("Layer specific mixing", layer) {
K0 : par_real("Mixing factor reference", [m 2, s-1], 0.5e-4, "Mixing factor when the B-V frequency is equal to the reference")
K0ice : par_real("Mixing factor reference under ice", [m 2, s-1], 0.5e-4)
}

par_group("Initial layer physical", layer) {
Expand Down Expand Up @@ -178,7 +180,7 @@ Authors: Magnus D. Norling

#TODO: Make wind mixing instead dependent on the B-V frequency also? One issue is to determine how much energy gets "used" in each layer.
var(basin.emix, [J], "Total wind mixing energy") {
A[vert.top]*sqrt(stress^3/layer.water.rho[vert.top])*time.step_length_in_seconds
(!ice_ind)*A[vert.top]*sqrt(stress^3/layer.water.rho[vert.top])*time.step_length_in_seconds
}

var(layer.water.sumV, [m 3]) {
Expand Down Expand Up @@ -208,8 +210,9 @@ Authors: Magnus D. Norling
}

var(layer.water.v_t, [m, s-1]) {
K := { K0ice if ice_ind, K0 otherwise },
dz_ := 0.5*(dz + dz[vert.below]),
safe_divide(K0, dz_*(Nfreq/N0)^alpha)
safe_divide(K, dz_*(Nfreq/N0)^alpha)
}

var(layer.water.v_s, [m, s-1]) {
Expand Down
3 changes: 2 additions & 1 deletion models/modules/nivafjord/fjordchem.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ module("NIVAFjord chemistry", version(0, 0, 5),
chem_par : preamble
) {
#TODO: Would be nice to unify easychem and fjordchem a bit more, maybe some shared code.
# Esp. for surface O2 exchange

par_group("Initial chem", layer) {
init_O2 : par_real("Initial O₂ saturation", [], 1, 0, 1)
Expand Down Expand Up @@ -145,7 +146,7 @@ module("NIVAFjord chemistry", version(0, 0, 5),
}

var(layer.water.o2satconc, [m g, l-1]) {
o2_saturation(temp, salin)*o2_mol_mass -> [m g, l-1]
o2_saturation(temp, salin)*o2_mol_mass ->>
} #@no_store

var(layer.water.o2sat, []) {
Expand Down
60 changes: 60 additions & 0 deletions models/nivafjord_isolated_basin_fpv_model.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@


model("NIVAFjord Isolated Basin FPV") {
"""
NIVAFjord in a single basin without open boundary conditions. Also, you can cover basins with FPV (floating photovoltaics).

It is also currently without horizontal exchange between basins, so it only works in a single one (or several isolated ones) for now.
"""

# TODO: FPV cover does not dynamically affect wind mixing (not sure to how large a degree that would happen).
extend("nivafjord_lake_model.txt")

fpv : compartment("FPV", basin_idx)

load("modules/airsea_fpv.txt",
module("AirSea FPV", air, basin, fpv, ice, heat, temp, precip, wind, g_rad, pressure, rho, a_hum, lwd, sw, attn, indicator,
evap, cos_z, loc(basin.freeze_t), loc(basin.area), loc(layer.water[vert.top]), loc(layer.water.heat[sw_vert.top])))

module("Basin inflow", version(0, 0, 0)) {

var(air.precip, [m m, day-1], "Precipitation")
var(air.temp, [deg_c], "Air temperature")


load("stdlib/seawater.txt", library("Sea oxygen"))
load("stdlib/physiochemistry.txt", library("Chemistry"), library("Water utils"))

# Water

flow : property("Basin inflow")
var(basin.flow, [m 3, s-1]) # Input series

# Just directing the catchment runoff to the top layer instead of doing the density check.
flux(out, layer.water[vert.top], [m 3, s-1], "Discharge from land to basin") { basin.flow->> }

# O2

par_group("Inflow oxygen") {
f_o2sat : par_real("Inflow O₂ saturation fraction", [], 0.9, 0, 1)
}

flux(out, layer.water.o2[vert.top], [k g, day-1], "Oxygen from land") {
inflow_t := air.temp, # Assume inflow temperature = air temperature (see also below)
land_conc := f_o2sat*o2_saturation(inflow_t, 0) * o2_mol_mass,
basin.flow*land_conc->>
}

# Heat / temperature

flux(out, layer.water.heat[vert.top], [J, day-1], "Heat from land") {
inflow_t := air.temp, # Assume inflow temperature = air temperature (see also above)
(water_temp_to_heat(basin.flow => [m 3], inflow_t) => [J, s-1]) ->>
}

# TODO: Add other substances that may be washed in.

# TODO: Also outflow?
}
}

2 changes: 1 addition & 1 deletion models/nivafjord_model.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ model("NIVAFjord") {

load("modules/nivafjord/basin.txt",
dims : preamble("NIVAFjord dimensions", all_basins, layer_idx, layer),
module("NIVAFjord basin", air, basin, layer, water, salt, heat, temp, salinity, pressure, wind, g_rad, rho, attn, z, dz, h, area, freeze_t, sw, vert, sw_vert, loc(sediment.heat), dims))
module("NIVAFjord basin", air, basin, layer, water, salt, heat, temp, salinity, pressure, wind, g_rad, rho, attn, z, dz, h, area, freeze_t, sw, loc(basin.ice.indicator), vert, sw_vert, loc(sediment.heat), dims))

load("modules/nivafjord/boundary_basin.txt",
module("NIVAFjord boundary", bnd_basin, bnd_layer, water, heat, salt, temp, salinity, dz, h, rho, pressure, vert, dims))
Expand Down
137 changes: 0 additions & 137 deletions models/nivafjord_simplycnp_isolated_basin_model.txt

This file was deleted.

0 comments on commit a971f44

Please sign in to comment.