model:

    domain:
        cls: SedimentDBLDomain
        init_params:
            cell_size: !unit 50 mum
            sediment_length: !unit 10 mm
            dbl_length: !unit 2 mm
            porosity: 0.6


    environment:

        irradiance:
            cls: Irradiance
            init_params:
                hours_total: !unit 4h
                day_fraction: 0.5

                channels:
                    - name: par
                      k0: !unit 15.3 1/cm

        oxy:
            cls: ModelVariable
            init_params:
                name: oxy
                create:
                    hasOld: true
                    value: !unit 0.0 mol/m**3

                constraints:
                    top: !unit 230 mumol/l
                    bottom: !unit 0.0 mol/l

                seed:
                    profile: linear


        D_oxy:
            cls: Process
            init_params:
                expr:
                    formula: porosity * D0_oxy

                params:
                    D0_oxy: !unit 0.03 cm**2/h
        # start: h2s
        h2s:
            cls: ModelVariable
            init_params:
                name: h2s
                create:
                    hasOld: true
                    value: !unit 0.0 mol/m**3

                constraints:
                    top: !unit 10.0 mumol/l
                    bottom: !unit 1e-3 mol/l

                clip_min: 0.0

                seed:
                    profile: linear

        D_h2s:
            cls: Process
            init_params:
                expr:
                    formula: porosity * D0_h2s
                params:
                    D0_h2s: !unit 0.02 cm**2/h
        # stop: h2s

        # start: aero_respire
        aero_respire:
            cls: Process
            init_params:
                expr:
                    formula: -Vmax * porosity * sed_mask * saturation(oxy, Km)
                params:
                    Vmax: !unit 1.0 mmol/l/h
                    Km: &aero_Km !unit 1e-5 mol/l
        # stop: aero_respire

        # start: abio_sulfoxid
        abio_sulfoxid:
            cls: Process
            init_params:
                expr:
                    formula: porosity * k * oxy * oxy * h2s * sed_mask
                params:
                    k: !unit -70.0 1/h/(mmol/l)**2
        # stop: abio_sulfoxid

    # start: equations
    equations:

        oxyEqn:

            transient: [domain.oxy, 1]

            diffusion: [env.D_oxy, 1]

            sources:
                - [env.abio_sulfoxid, 2]

                - [env.aero_respire, 1]

        h2sEqn:

            transient: [domain.h2s, 1]

            diffusion: [env.D_h2s, 1]

            sources:
                - [env.abio_sulfoxid, 1]
    # stop: equations

    # start: formulae
    formulae:

        saturation:
            vars: [x, Km]
            expr: x / (Km + x)
    # stop: formulae

simulation:
    simtime_total: !unit 8h
    simtime_lims: [0.1, 180]
    max_residual: 1e-13
