Skip to content

Commit

Permalink
Merge pull request #65 from ScottLogic/network-changes
Browse files Browse the repository at this point in the history
SFD-103 Update Network Calculations
  • Loading branch information
sdun-scottlogic authored Jun 4, 2024
2 parents 96763a0 + e4e28b9 commit 152c9e3
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,34 +58,12 @@ <h4 class="tce-text-lg">Power consumption</h4>
</tr>
</thead>
<tbody>
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">Laptop</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">17</td>
</tr>
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">Desktop</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">72</td>
</tr>
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">Server</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">400</td>
</tr>
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">Network</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">150</td>
</tr>
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">Mobile</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">1</td>
</tr>
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">Tablet</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">3</td>
</tr>
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">Monitor</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">30</td>
</tr>
@for (device of deviceInfo; track $index) {
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">{{ device.name }}</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">{{ device.info.averagePower }}</td>
</tr>
}
</tbody>
</table>
<p class="tce-text-sm">
Expand Down Expand Up @@ -122,7 +100,7 @@ <h4 class="tce-text-lg">Carbon Intensity</h4>
<h4 class="tce-text-lg">Upstream Emissions</h4>
<p class="tce-text-sm">
Each class of device is given an average amount of embodied carbon and a lifespan, based on averages taken from
manufacturer provided Product Carbon Footprint documentation. At present these are:
manufacturer provided Product Carbon Footprint documentation*. At present these are:
</p>
<table class="tce-w-fit">
<thead>
Expand All @@ -135,41 +113,17 @@ <h4 class="tce-text-lg">Upstream Emissions</h4>
</tr>
</thead>
<tbody>
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">Laptop</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">230</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">4</td>
</tr>
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">Desktop</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">400</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">4</td>
</tr>
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">Server</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">1450</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">4</td>
</tr>
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">Network</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">650 *</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">4</td>
</tr>
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">Mobile</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">54</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">3</td>
</tr>
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">Tablet</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">134</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">3</td>
</tr>
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">Monitor</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">350</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">6</td>
</tr>
@for (device of deviceInfo; track $index) {
<tr>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">{{ device.name }}</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">
{{ device.info.averageEmbodiedCarbon }}
</td>
<td class="tce-text-sm tce-border tce-border-slate-300 tce-px-2 tce-py-1">
{{ device.info.averageLifespan }}
</td>
</tr>
}
</tbody>
</table>
<p class="tce-text-sm tce-italic">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { siteTypeInfo } from '../estimation/estimate-downstream-emissions';
import { PurposeOfSite, WorldLocation, locationArray, purposeOfSiteArray } from '../types/carbon-estimator';
import { DecimalPipe } from '@angular/common';
import { CarbonIntensityService } from '../services/carbon-intensity.service';
import { desktop, laptop, mobile, monitor, network, server, tablet } from '../estimation/device-type';

const purposeDescriptions: Record<PurposeOfSite, string> = {
information: 'Information',
Expand Down Expand Up @@ -40,6 +41,36 @@ export class AssumptionsAndLimitationComponent implements AfterContentInit {
data: siteTypeInfo[purpose].averageMonthlyUserData,
}));
readonly locationCarbonInfo;
readonly deviceInfo = [
{
name: 'Laptop',
info: laptop,
},
{
name: 'Desktop',
info: desktop,
},
{
name: 'Server',
info: server,
},
{
name: 'Network',
info: network,
},
{
name: 'Mobile',
info: mobile,
},
{
name: 'Tablet',
info: tablet,
},
{
name: 'Monitor',
info: monitor,
},
];

@ViewChild('assumptionsLimitation', { static: true }) public assumptionsLimitation!: ElementRef<HTMLDivElement>;

Expand Down
6 changes: 3 additions & 3 deletions src/app/estimation/device-type.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ describe('Device type of server', () => {

describe('Device type of network', () => {
it('Estimates kWh of 1 network device', () => {
expect(network.estimateYearlyEnergy(1)).toBeCloseTo(1314);
expect(network.estimateYearlyEnergy(1)).toBeCloseTo(762.12);
});

it('Estimates kWh of 30 desktops', () => {
expect(network.estimateYearlyEnergy(30)).toBeCloseTo(39420);
it('Estimates kWh of 30 network devices', () => {
expect(network.estimateYearlyEnergy(30)).toBeCloseTo(22863.6);
});

it('Estimates upstream emissions of 1 network device', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/estimation/device-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class AverageDeviceType extends DeviceType {
export const laptop = new DeviceType(17, 8 * 230, 230, 4);
export const desktop = new DeviceType(72, 8 * 230, 400, 4);
export const server = new DeviceType(400, 24 * 365, 1450, 4);
export const network = new DeviceType(150, 24 * 365, 650, 4);
export const network = new DeviceType(87, 24 * 365, 650, 4);
export const mobile = new DeviceType(1, 24 * 365, 54, 3);
export const tablet = new DeviceType(3, 24 * 365, 134, 3);
export const monitor = new DeviceType(30, 8 * 230, 350, 6);
Expand Down
24 changes: 12 additions & 12 deletions src/app/services/carbon-estimation.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ describe('CarbonEstimationService', () => {
const result = service.calculateCarbonEstimation(hardwareInput);
expectPartialEstimationCloseTo(result, {
upstreamEmissions: {
employee: 5.78,
server: 7.64,
network: 3.43,
employee: 6.53,
server: 8.64,
network: 3.87,
},
directEmissions: {
employee: 2.89,
server: 58.37,
network: 21.89,
employee: 3.27,
server: 65.97,
network: 11.72,
},
});
});
Expand All @@ -217,14 +217,14 @@ describe('CarbonEstimationService', () => {
const result = service.calculateCarbonEstimation(hardwareInput);
expectPartialEstimationCloseTo(result, {
upstreamEmissions: {
employee: 6.21,
server: 8.21,
network: 3.68,
employee: 6.8,
server: 8.99,
network: 4.03,
},
directEmissions: {
employee: 1.55,
server: 62.71,
network: 17.64,
employee: 1.7,
server: 68.65,
network: 9.83,
},
});
});
Expand Down
6 changes: 3 additions & 3 deletions src/app/services/carbon-estimation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class CarbonEstimationService {
const desktopCount = calculateCeilingPercentage(desktopPercent, headCount);
const laptopCount = calculateCeilingPercentage(laptopPercent, headCount);
const serverCount = this.estimateServerCount(formValue);
const employeeNetworkCount = estimateNetworkDeviceCount(desktopCount);
const employeeNetworkCount = estimateNetworkDeviceCount(desktopCount + laptopCount);
const serverNetworkCount = estimateNetworkDeviceCount(serverCount);
const monitorCount = headCount;

Expand All @@ -75,7 +75,7 @@ export class CarbonEstimationService {
return [
createDeviceUsage(desktop, 'employee', employeeIntensity, desktopCount),
createDeviceUsage(laptop, 'employee', employeeIntensity, laptopCount),
createDeviceUsage(network, 'network', employeeIntensity, employeeNetworkCount, ON_PREMISE_AVERAGE_PUE),
createDeviceUsage(network, 'network', employeeIntensity, employeeNetworkCount),
createDeviceUsage(server, 'server', onPremIntensity, serverCount, ON_PREMISE_AVERAGE_PUE),
createDeviceUsage(network, 'network', onPremIntensity, serverNetworkCount, ON_PREMISE_AVERAGE_PUE),
createDeviceUsage(monitor, 'employee', employeeIntensity, monitorCount),
Expand Down Expand Up @@ -107,7 +107,7 @@ function calculateCeilingPercentage(percentage: number, value: number) {
}

function estimateNetworkDeviceCount(deviceCount: number) {
return Math.ceil(deviceCount / 2);
return Math.ceil(deviceCount / 16);
}

function formatObject(input: unknown): string {
Expand Down

0 comments on commit 152c9e3

Please sign in to comment.