Closed fershad closed 1 month ago
@mrchrisadams when you've got some time, can you please mark my homework.
Added values and tests for the SWDM v4 Rating Scale to this update
Thanks @mrchrisadams I've fixed those constants & refactored a bit of code that was duplicated within and across models.
This is ready to merge & should be the final code change before publishing v0.16.0
Triage
Type of change
Please select any of the below items that are appropriate.
This pull request:
Related issue/s
Please list below any issues this pull request is related to.
119
Docs changes required
Do any changes made in this pull request require parts of the CO2.js documentation to be updated?
If you answered "Yes", please create an corresponding issue in our Developer Documentation repository.
Describe the changes made in this pull request
As clearly as possible, describe the changes made in the pull request. You should at least detail "what changes have been made" and "what the results of these changes will be".
These changes add the newer Sustainable Web Design Model version 4 calculation into CO2.js. This update DOES NOT remove the existing version 3 methodology which will continue to remain the default in CO2.js for the time being. Developers will have the option to opt-in to using the update version 4 methodology in their projects. They can do this when instantiating a new CO2 object that using the Sustainable Web Design Model. Code examples are below:
The
version
key accepts a value of typenumber
that must equal to 4. If that is not set, then the version 3 calculations are used by CO2.js.Changes to outputs
Functionality wise, there are no changes between version 3 and version 4 of CO2.js. The
perByte
,perVisit
,perByteTrace
, andperVisitTrace
functions all remain the same and accept the same inputs in both versions. The outputs of these functions also do no change by default.However, when using the
perByteTrace
orperVisitTrace
functions, developers can now pass in agreenHostingFactor
value for use in the estimates. This value is used by the respective calculation if thegreen
parameter passed into the function isfalse
. Whengreen === true
then theGREEN_HOSTING_FACTOR
used is set to1.0
. This reflects a continuation of the functionality that exists in Sustainable Web Design version 3 when changing the grid intensity of the data center segment (see: #197)Another important change to the output is seen when users select to return results per segment. These give a more detailed breakdown of the emissions estimates across each system segment. In SWDM version 4, emissions estimates are further separated into
operational
andembodied
emissions. These are now all returned when a user asks for segmented results.Other things to note
The SWD Rating Scale has not yet been added to the version 4 methodology. It could be included later in this PR, or via another PR if this one gets merged first.