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

Updating for error hunt results #17

Merged
merged 3 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/sources/modules/src/scaleup_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ growth numbers
A dataframe with all important growth numbers

### .determine_average_productivity
[source](https://github.com/allfed/Seaweed-Upscaling-Model/blob/master/src/scaleup_model.py/#L200)
[source](https://github.com/allfed/Seaweed-Upscaling-Model/blob/master/src/scaleup_model.py/#L210)
```python
.determine_average_productivity(
growth_rate_fraction, days_to_run, percent_usable_for_growth,
Expand Down Expand Up @@ -104,7 +104,7 @@ per area and day and the harvest intervall


### self_shading
[source](https://github.com/allfed/Seaweed-Upscaling-Model/blob/master/src/scaleup_model.py/#L255)
[source](https://github.com/allfed/Seaweed-Upscaling-Model/blob/master/src/scaleup_model.py/#L265)
```python
.self_shading(
density
Expand All @@ -131,7 +131,7 @@ the growth rate fraction


### calculate_seaweed_need
[source](https://github.com/allfed/Seaweed-Upscaling-Model/blob/master/src/scaleup_model.py/#L274)
[source](https://github.com/allfed/Seaweed-Upscaling-Model/blob/master/src/scaleup_model.py/#L284)
```python
.calculate_seaweed_need(
global_pop, calories_per_person_per_day, food_waste,
Expand Down Expand Up @@ -162,7 +162,7 @@ limited by the iodine content of the seaweed


### seaweed_farm_area_per_day
[source](https://github.com/allfed/Seaweed-Upscaling-Model/blob/master/src/scaleup_model.py/#L305)
[source](https://github.com/allfed/Seaweed-Upscaling-Model/blob/master/src/scaleup_model.py/#L315)
```python
.seaweed_farm_area_per_day(
day
Expand All @@ -188,7 +188,7 @@ the area that can be built per day


### logistic_curve
[source](https://github.com/allfed/Seaweed-Upscaling-Model/blob/master/src/scaleup_model.py/#L326)
[source](https://github.com/allfed/Seaweed-Upscaling-Model/blob/master/src/scaleup_model.py/#L336)
```python
.logistic_curve(
x, max_L, k, x0, off
Expand All @@ -214,7 +214,7 @@ Returns


### run_model
[source](https://github.com/allfed/Seaweed-Upscaling-Model/blob/master/src/scaleup_model.py/#L341)
[source](https://github.com/allfed/Seaweed-Upscaling-Model/blob/master/src/scaleup_model.py/#L351)
```python
.run_model(
optimal_growth_rate, days_to_run, global_pop, calories_per_person_per_day,
Expand Down
22 changes: 11 additions & 11 deletions mkgendocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ copyright: ALLFED

#This specifies the autogeneration portion
pages:
- page: "modules/src/scaleup_model.md"
source: "src/scaleup_model.py"
classes:
- SeaweedScaleUpModel
functions:
- self_shading
- calculate_seaweed_need
- seaweed_farm_area_per_day
- logistic_curve
- run_model

- page: "modules/src/plotter.md"
source: "src/plotter.py"
functions:
Expand All @@ -23,14 +34,3 @@ pages:
functions:
- prep_data

- page: "modules/src/scaleup_model.md"
source: "src/scaleup_model.py"
classes:
- SeaweedScaleUpModel
functions:
- self_shading
- calculate_seaweed_need
- seaweed_farm_area_per_day
- logistic_curve
- run_model

7,022 changes: 3,511 additions & 3,511 deletions results/global/150tg/harvest_df_cluster_0.csv

Large diffs are not rendered by default.

7,022 changes: 3,511 additions & 3,511 deletions results/global/150tg/harvest_df_cluster_2.csv

Large diffs are not rendered by default.

7,022 changes: 3,511 additions & 3,511 deletions results/global/16tg/harvest_df_cluster_0.csv

Large diffs are not rendered by default.

7,022 changes: 3,511 additions & 3,511 deletions results/global/16tg/harvest_df_cluster_2.csv

Large diffs are not rendered by default.

7,022 changes: 3,511 additions & 3,511 deletions results/global/27tg/harvest_df_cluster_1.csv

Large diffs are not rendered by default.

7,022 changes: 3,511 additions & 3,511 deletions results/global/27tg/harvest_df_cluster_2.csv

Large diffs are not rendered by default.

7,022 changes: 3,511 additions & 3,511 deletions results/global/37tg/harvest_df_cluster_1.csv

Large diffs are not rendered by default.

7,022 changes: 3,511 additions & 3,511 deletions results/global/37tg/harvest_df_cluster_2.csv

Large diffs are not rendered by default.

7,022 changes: 3,511 additions & 3,511 deletions results/global/47tg/harvest_df_cluster_1.csv

Large diffs are not rendered by default.

7,022 changes: 3,511 additions & 3,511 deletions results/global/47tg/harvest_df_cluster_2.csv

Large diffs are not rendered by default.

7,022 changes: 3,511 additions & 3,511 deletions results/global/5tg/harvest_df_cluster_1.csv

Large diffs are not rendered by default.

7,022 changes: 3,511 additions & 3,511 deletions results/global/5tg/harvest_df_cluster_2.csv

Large diffs are not rendered by default.

7,022 changes: 3,511 additions & 3,511 deletions results/global/control/harvest_df_cluster_0.csv

Large diffs are not rendered by default.

7,022 changes: 3,511 additions & 3,511 deletions results/global/control/harvest_df_cluster_1.csv

Large diffs are not rendered by default.

155 changes: 155 additions & 0 deletions scripts/Bug hunting.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Finding agreement with Vasco"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# Import the model\n",
"from src.scaleup_model import run_model\n",
"from src.preprocessing import prep_data\n",
"from src.plotter import create_plots"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# Go up one directory\n",
"import os\n",
"os.chdir(\"..\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Initialize the model\n",
"optimal_growth_rate = 30 # % per day\n",
"days_to_run = 3600 - 3 * 30 # 120 month at 30 days per month (and skip the first three months before the nuclear war)\n",
"global_pop = 7000000000\n",
"calories_per_person_per_day = 2250\n",
"harvest_loss = 20 # % of the harvest that is lost\n",
"food_waste = 13 # https://www.researchsquare.com/article/rs-1446444/v1\n",
"calories_per_t_seaweed_wet = 288200 # see Efficiency.ipynb\n",
"food_limit = 0.15 # amount of food that can be replaced by seaweed\n",
"# https://academic.oup.com/jcem/article/87/12/5499/2823602\n",
"feed_limit = 0.05 # amount of feed that can be replaced by seaweed\n",
"biofuel_limit = 0.5 # amount of biofuel that can be replaced by seaweed\n",
"# percent of the area of the module that can acutally be used for food production.\n",
"# Rest is needed for things like lanes for harvesting\n",
"percent_usable_for_growth = 50 # %\n",
"# Which scenario to run\n",
"scenarios = [\"150tg\"]\n",
"location = \"global\"\n",
"number_of_clusters = 3\n",
"consumption_aim = 70 # % of the global need is the aim for the building of the farms"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Start preprocessing for scenario 150tg\n"
]
}
],
"source": [
"# do the preprocessing to get the data in the right format\n",
"# Go through all nuclear war scenarios\n",
"for scenario in scenarios:\n",
" print(\"Start preprocessing for scenario \" + scenario)\n",
" path = \"data\"\n",
" prep_data(scenario, location, number_of_clusters)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running scenario 150tg\n",
"Cluster 0 has a mean growth rate (fraction of max growth rate) of 0.11368341430016159\n",
"stable_harvest_intervall 87.0\n",
"stable_harvest_for_food 1931.0029876298024\n",
"productivity_day_km2 22.195436639423015\n",
"calculating yield for cluster 0\n",
"Cluster 1 has a mean growth rate (fraction of max growth rate) of 0.0004594581205788031\n",
"stable_harvest_intervall None\n",
"stable_harvest_for_food None\n",
"productivity_day_km2 None\n",
"Not enough productivity in cluster for production 1, skipping it\n",
"Cluster 2 has a mean growth rate (fraction of max growth rate) of 0.43795151408829613\n",
"stable_harvest_intervall 23.0\n",
"stable_harvest_for_food 1926.66699609971\n",
"productivity_day_km2 83.76813026520479\n",
"calculating yield for cluster 2\n",
"done\n"
]
}
],
"source": [
"# Run the model\n",
"run_model(\n",
" optimal_growth_rate,\n",
" days_to_run,\n",
" global_pop,\n",
" calories_per_person_per_day,\n",
" harvest_loss,\n",
" food_waste,\n",
" calories_per_t_seaweed_wet,\n",
" food_limit,\n",
" feed_limit,\n",
" biofuel_limit,\n",
" percent_usable_for_growth,\n",
" scenarios,\n",
" location,\n",
" number_of_clusters,\n",
")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "seaweed-upscaling-model",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.12"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
2 changes: 1 addition & 1 deletion scripts/Efficieny.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
"version": "3.9.12"
},
"vscode": {
"interpreter": {
Expand Down
Loading
Loading