openearth / aeolis-python

A process-based model for simulating supply-limited aeolian sediment transport
http://aeolis.readthedocs.io/
GNU General Public License v3.0
34 stars 26 forks source link

Test: 2D base case #60

Closed bartvanwesten closed 1 year ago

bartvanwesten commented 1 year ago

We need to implement tests for the following scenario:

Description

Testing the transport-related functionalities step-wise for a 5x5 2D grid without supply-limitations. The test includes starting, running and finishing the model, checking the generation of output files and the actual values of generated output. The main aim is to use as many as defaults as possible, to test reproducability / backwards-compatibility.

Code Reference

[ Permalink to code for which the test is required ]

Test Cases

Case:

Sierd commented 1 year ago

Test should ideally include a check for continuity. Which means for any domain:

This gets complicated when having more grain sizes than 1.

niketagrawal commented 1 year ago

Implementation of this test is being done here. Changes are work in progress.

Suggestions for testcases to include:

niketagrawal commented 1 year ago

Changing the solver and time step did not influence the mass deficit. Possible changes needed in the code @Sierd

issue

niketagrawal commented 1 year ago

To do: Test cases to check basic functionality of the model:

Sierd commented 1 year ago

@niketagrawal, I have drafted a test for continuity. Could you try and run this and see if this works. The idea is that frac is a very small number at the end of the simulation (the plot shows frac for every timestep).

This seems to work for me, can you double check?

import netCDF4
import numpy as np
import matplotlib.pyplot as plt

fname = r'.\examples\1D\case1_small_waves\aeolis.nc'

with netCDF4.Dataset(fname, 'r') as ds:

        # dimensions
        dt = np.diff(ds.variables['time'][:])[0]
        dx = np.diff(ds.variables['x'][0,:])[0]
        zb = ds.variables['zb'][:,:,:]
        qs = ds.variables['qs']        
        Ct = np.sum(ds.variables['Ct'][:,:,:,:], axis=-1)

        steps = zb.shape[0]-1
        dV=np.zeros(steps)
        frac=np.zeros(steps)

        for i in range(0,steps):
            # bed level change
            dz = zb[i,:,:] - zb[0,:,:]
            V1 = dz * dx #* dy

            # volume loss over downwind border
            V2 = qs[:i,0,-1,0]  * dt / (2650. * .6)

            # volume in saltation
            V3 = Ct[i,:,:] * dx / (2650. * .6)

            # metrics
            E = np.abs(np.minimum(0., V1).sum())
            D = np.abs(np.maximum(0., V1).sum())
            dV[i] = np.abs(V1.sum() + V2.sum() + V3.sum())
            frac = dV/E

plt.plot(frac)
plt.show()