Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wastewater nutrient concentration (g/use) #81

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

val-ismaili
Copy link
Collaborator

@val-ismaili val-ismaili commented Mar 12, 2025

Closes #80 #79 #76

This PR focuses on addressing the incorrect implementation of nutrient concentrations to discharge flow. The key change being that input statistics are provided in g/use. Implying that regardless of the discharge volume for and enduse discharge event, the same volume of nutrients will be deposited. As per the norm with pysimdeum, stochastic behaviour is implemented by using input data as an average to sample from a normal distribution. This is then used to calculate the specific concentration in g/L for each discharge event.

This work uncovered a gap in how the Wc enduse data is provided. The use of half-flush and full flush, though strongly correlated with, does not necessarily imply directly faeces or urine use. Though this isn't relevant at simulation stages for flows (you just care whether it is full or half flush as that changes flow volume), we do care whether a urine or faeces use is sampled when calculating nutrient concentrations. So this is added as metadata to the discharge event. Similarly other enduses with usage subtypes (e.g. KitchenTap drinking water or dishes) have their enduse usage tracked through metadata. The nutrient config file allows the user to provide specific stats for each usage subtype.

To accomodate this metadata I thought it made sense to not alter the discharge data array directly since this metadata would just add dimensions and bulk out the file even more. So I embedded the existing discharge object datarray within a xarray.Dataset. The discharge data array and discharge_events are stored within this. So the discharge object return by a command like consumption, discharge = house.simulate(duration='1 day', num_patterns=1, simulate_discharge=True) is actually axarray.Dataset.

Simple to access by discharge.discharge or discharge.discharge_events. This new discharge_events metadata is a simple structure of a list of dictionaries for each discharge event of the structure;

{'enduse': 'Wc',
'usage': 'urine',
'start': 186,
'end': 192}

To run the code simply provide the discharge dataset as an argument to the function assign_discharge_nutrients

from pysimdeum.core import utils

utils.assign_discharge_nutrients(discharge)

@val-ismaili val-ismaili requested review from sophieoneill and BramHillebrand and removed request for sophieoneill March 12, 2025 17:05
@val-ismaili val-ismaili added bug Something isn't working documentation Improvements or additions to documentation labels Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
1 participant