-
Notifications
You must be signed in to change notification settings - Fork 164
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
revision of SCP implementation for milk and meat alternatives #698
Conversation
s15_scp_protein_per_milk protein needed as ingredient for scp milk (mass per 100g milk) / 3.3 / | ||
s15_scp_fat_to_kcal conversion factor (kcal per gram of fat) / 8.79 / | ||
s15_scp_sugar_to_kcal conversion factor (kcal per gram of sugar) / 3.87 / | ||
s15_scp_protein_to_kcal conversion factor (kcal per gram of protein) / 4.27 / |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s15_scp_fat_to_kcal , s15_scp_sugar_to_kcal, s15_scp_protein_to_kcal these are the specific conversion factors for milk. It would be worth clarifying this in the scalar name. If demand for sugar and oil is also implemented for meat, then this too would have a specific caloric conversion factors that are different from milk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one comment concerning the used units where a different unit and/or a better unit description could be helpful
@@ -183,7 +184,12 @@ parameters | |||
; | |||
|
|||
scalars | |||
s15_year Current year as integer value (yr) / 2000 / | |||
s15_scp_fat_per_milk fat needed as ingredient for scp milk (mass per 100g milk) / 3.3 / |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the unit. Is it g/100g ?! Why not just a mass ratio (1:1)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one small comment regarding the naming of s15_scp_fat_to_kcal , s15_scp_sugar_to_kcal and s15_scp_protein_to_kcal, these are specific to milk, it would be worth clarifying this in their names
CHANGELOG.md
Outdated
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). | |||
### changed | |||
- **21_trade** refactor equations for enhanced readablility and improve documentation | |||
- **script** rewrite of merge_report.R based on rds files and rbind, which allows for more flexibility when merging reports. Avoid inconsistent use of "GLO" instead of "World" in report.rds files. | |||
- **15_food** revision of SCP implementation for milk. Added demand for plant oil and sugar as ingredients for milk production using single cell protein. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
"milk production" --> "(animal-free) milk alternative" or similar?
s15_scp_fat_per_milk fat needed as ingredient for scp milk (g per 100g) / 3.3 / | ||
s15_scp_sugar_per_milk sugar needed as ingredient for scp milk (g per 100g) / 4.7 / | ||
s15_scp_protein_per_milk protein needed as ingredient for scp milk (g per 100g) / 3.3 / | ||
s15_scp_fat_to_kcal_milk conversion factor (kcal per gram of fat) / 8.79 / | ||
s15_scp_sugar_to_kcal_milk conversion factor (kcal per gram of sugar) / 3.87 / | ||
s15_scp_protein_to_kcal_milk conversion factor (kcal per gram of protein) / 4.27 / | ||
; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add information regarding dry or wet matter basis.
s15_scp_fat_per_milk fat needed as ingredient for scp milk (g per 100g) / 3.3 / | ||
s15_scp_sugar_per_milk sugar needed as ingredient for scp milk (g per 100g) / 4.7 / | ||
s15_scp_protein_per_milk protein needed as ingredient for scp milk (g per 100g) / 3.3 / | ||
s15_scp_fat_to_kcal_milk conversion factor (kcal per gram of fat) / 8.79 / | ||
s15_scp_sugar_to_kcal_milk conversion factor (kcal per gram of sugar) / 3.87 / | ||
s15_scp_protein_to_kcal_milk conversion factor (kcal per gram of protein) / 4.27 / |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add information regarding dry or wet matter basis.
*' Reduction of ruminant meat and dairy products (kfo_rd): | ||
p15_kcal_pc_iso(t,iso,kfo_rd) = p15_kcal_pc_iso(t,iso,kfo_rd) * i15_rumdairy_scp_fadeout(t,iso); | ||
*' | ||
*' Plant oil and sugar demands as ingredients for milk production using single cell protein |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
"milk production" --> "(animal-free) milk alternative" or similar?
p15_kcal_pc_calibrated(t,i,kfo_rd) = p15_kcal_pc_calibrated(t,i,kfo_rd) * i15_rumdairy_scp_fadeout(t,i); | ||
|
||
*' | ||
*' Plant oil and sugar demands as ingredients for milk production using single cell protein |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
"milk production" --> "(animal-free) milk alternative" or similar?
p15_kcal_pc_calibrated(t,i,kfo_rd) = p15_kcal_pc_calibrated(t,i,kfo_rd) * i15_rumdairy_scp_fadeout(t,i); | ||
|
||
*' | ||
*' Plant oil and sugar demands as ingredients for milk production using single cell protein |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion:
"milk production" --> "(animal-free) milk alternative" or similar?
p15_kcal_pc_iso(t,iso,"oils") = p15_kcal_pc_iso(t,iso,"oils") | ||
+ sum(kfo_rd$sameas(kfo_rd,"livst_milk"), p15_kcal_pc_iso_scp(t,iso,kfo_rd)) | ||
* (s15_scp_fat_per_milk * s15_scp_fat_to_kcal_milk) / (s15_scp_protein_per_milk * s15_scp_protein_to_kcal_milk); | ||
*' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think '1/s15_scp_protein_to_kcal_milk' has to be replaced by 'i15_protein_to_kcal_ratio(t,"scp")' (the same for line 138 below).
The reference unit for replacement of milk with scp-milk is protein. Based on the estimation of how much scp-protein is needed to replace cow milk, we can calculate here, how much additional sugar and oil is required to create an "scp milk" with similar properties like cow milk.
Furthermore, I don't understand why the conversion factors for kcal per gram of fat and sugar should be specific for milk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your review!
If I understand correctly, we could do the following:
Instead of
p15_kcal_pc_calibrated_scp(t,i,kfo_rd) = p15_kcal_pc_calibrated(t,i,kfo_rd) * (1-i15_rumdairy_scp_fadeout(t,i)) * i15_protein_to_kcal_ratio(t,kfo_rd) / i15_protein_to_kcal_ratio(t,"scp");
we could do
p15_protein_pc_calibrated_scp(t,i,kfo_rd) = p15_kcal_pc_calibrated(t,i,kfo_rd) * (1-i15_rumdairy_scp_fadeout(t,i)) * i15_protein_to_kcal_ratio(t,kfo_rd);
Thus keeping the unit in protein.
This would also change this calculation of p15_kcal_pc_calibrated(t,i,"scp"):
p15_kcal_pc_calibrated(t,i,"scp") = p15_kcal_pc_calibrated(t,i,"scp") + sum(kfo_rd, p15_protein_pc_calibrated_scp(t,i,kfo_rd))/i15_protein_to_kcal_ratio(t,"scp");
This would simplify the addition of oil to:
p15_kcal_pc_calibrated(t,i,"oils") = p15_kcal_pc_calibrated(t,i,"oils") + sum(kfo_rd$sameas(kfo_rd,"livst_milk"), p15_protein_pc_calibrated_scp(t,i,kfo_rd)) / s15_scp_protein_per_milk * s15_scp_fat_per_milk;
For sugar:
p15_kcal_pc_calibrated(t,i,"sugar") = p15_kcal_pc_calibrated(t,i,"sugar") + sum(kfo_rd$sameas(kfo_rd,"livst_milk"), p15_protein_pc_calibrated_scp(t,i,kfo_rd)) / s15_scp_protein_per_milk * s15_scp_sugar_per_milk;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slovat Do you follow here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I completely understand. If I get it right, you are saying rather than going through kcal, work with mass of protein. Based on the mass of SCP milk protein produced, calculate the amount of fat and sugar demand then based on their mass ratio with protein in milk? I.e. if I produce 20 Mt milk protein and the mass ratio of protein to fat is 1:1, I would also need 20 Mt fat?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weindl I'm not sure what's best to use for the conversion factors for kcal per gram of fat and sugar and what level of detail is usually used in MAgPIE. We could use a generic factor of 4 kcal/g protein or sugar and 9 kcal/g fat. But if I'm not mistaken, caloric densities reflect energy available for humans and this includes something about digestability. Because different food products have different digestabilities, a gram of sugar in say milk is different than in wheat and so there is different amounts available depending on the food product. This means there are specific caloric conversion factors for differnet food products (they don't vary hugely between different products), but if this is not normally done in MAgPIE, we can just use generic factors too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @flohump Your suggestion looks good. The only thing I noticed: as long as the meaning of the scalars does not chnage, we still need 's15_scp_fat_to_kcal_milk' and 's15_scp_sugar_to_kcal_milk' to convert mass to kcal, as required by e.g. 'p15_kcal_pc_calibrated(t,i,"oils")'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flohump In general, your approach makes sense to me, but the sugar and fat equations need an additional factor at the end translating g sugar / fat to kcal. Right now, equation units would be
kcal = kcal + g protein / (g protein / 100 g milk) * g fat / 100 g milk = kcal + g fat (or g sugar, respectively)
p15_kcal_pc_calibrated(t,i,"oils") = p15_kcal_pc_calibrated(t,i,"oils") + sum(kfo_rd$sameas(kfo_rd,"livst_milk"), p15_protein_pc_calibrated_scp(t,i,kfo_rd)) / s15_scp_protein_per_milk * s15_scp_fat_per_milk * fm_nutrition_attributes(t,"oils", "kcal");
p15_kcal_pc_calibrated(t,i,"sugar") = p15_kcal_pc_calibrated(t,i,"sugar") + sum(kfo_rd$sameas(kfo_rd,"livst_milk"), p15_protein_pc_calibrated_scp(t,i,kfo_rd)) / s15_scp_protein_per_milk * s15_scp_sugar_per_milk * fm_nutrition_attributes(t, "sugar" ,"kcal");
Few fine-tuning question: Are these sugar and fat amounts / 100g the ones that are consumed at the end or the amounts that go into the SCP production process, with different amounts actually consumed?
And is it important for reporting of food profiles that we're splitting a single category (milk) into three distinct ones (SCP, sugar, oils) instead of summing these values to a single SCP kcal value?
Edit: Ah, @weindl was faster. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now
p15_kcal_pc_calibrated(t,i,"sugar") = p15_kcal_pc_calibrated(t,i,"sugar") | ||
+ sum(kfo_rd$sameas(kfo_rd,"livst_milk"), p15_kcal_pc_calibrated_scp(t,i,kfo_rd)) | ||
* (s15_scp_sugar_per_milk * s15_scp_sugar_to_kcal_milk) / (s15_scp_protein_per_milk * s15_scp_protein_to_kcal_milk); | ||
*' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same changes necessary as in the other module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment in exodietmacro.gms. Process makes sense to me, but the suggested equations seem to need unit checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this version. Looks good!
p15_kcal_pc_iso(t,iso,"oils") = p15_kcal_pc_iso(t,iso,"oils") | ||
+ sum(kfo_rd$sameas(kfo_rd,"livst_milk"), p15_kcal_pc_iso_scp(t,iso,kfo_rd)) | ||
* (s15_scp_fat_per_milk * s15_scp_fat_to_kcal_milk) / (s15_scp_protein_per_milk * s15_scp_protein_to_kcal_milk); | ||
*' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just one tiny description suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please double check units
I added reporting variables for oil and sugar as inredient for scp-based met and milk alternatives in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The addition to the code looks good in general. I have only one comment to the naming of a new scalar.
s15_scp_fat_per_milk Fat needed as ingredient for scp-based milk alternative (g per 100g wet matter) / 3.3 / | ||
s15_scp_sugar_per_milk Sugar needed as ingredient for scp-based milk alternative (g per 100g wet matter) / 4.7 / | ||
s15_scp_protein_per_milk Protein needed as ingredient for scp-based milk alternative (g per 100g wet matter) / 3.3 / | ||
s15_scp_fat_per_meat Fat content of microbial biomass based on Solein from Solar foods (t fat per t DM) / 0.05 / |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to rename the scalar 's15_scp_fat_per_meat' to better reflect its meaning ( ="fat content of microbial biomass).
For me 's15_scp_fat_per_meat' sounds like a scalar indicating how much fat is needed to produce a unit of final scp-meat product in wet matter, which is not the case.
Maybe 's15_scp_fat_content' or similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The renaming would also require changes in the magpie4.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I revised the scalar name in the GAMS code and the magpie4
R library.
🐦 Description of this PR 🐦
🔧 Checklist for PR creator 🔧
Label pull request from the label list.
Self-review own code
magpie4
R library has been updated accordingly and backwards compatible where necessary.scenario_config.csv
has been updated accordingly (important ifdefault.cfg
has been updated)Document changes
CHANGELOG.md
goxygen::goxygen()
and verify the modified code is properly documentedPerform test runs
Rscript start.R --> "compilation check"
Rscript start.R --> "test runs"
Rscript start.R --> "test runs"
📉 Performance changes 📈
🚨 Checklist for reviewer 🚨
CHANGELOG
is updated correctly