Skip to content

Commit

Permalink
feat: allow users to change the insulation of walls and windows (#57)
Browse files Browse the repository at this point in the history
* feat: add new wall materials
* feat: add window size and insulations
* feat: allow to update the composition of materials
  • Loading branch information
ReidyT authored Nov 28, 2024
1 parent f6270d8 commit a8bd1df
Show file tree
Hide file tree
Showing 36 changed files with 1,923 additions and 498 deletions.
52 changes: 52 additions & 0 deletions src/config/buildingMaterials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { BuildingMaterial } from '@/models/BuildingMaterial';

export const BUILDING_MATERIALS = {
Aerogel: BuildingMaterial.create({
name: 'Aerogel',
price: 10_000,
thermalConductivity: 0.021,
thickness: 0.16,
}),
FiberGlass: BuildingMaterial.create({
name: 'Fiber Glass',
price: 3_000,
thermalConductivity: 0.115,
thickness: 0.16,
}),
XPSFoam: BuildingMaterial.create({
name: 'XPS Foam',
price: 10,
thermalConductivity: 0.024,
thickness: 0.16,
}),
MineralWool: BuildingMaterial.create({
name: 'Mineral Wool',
price: 7,
thermalConductivity: 0.03,
thickness: 0.16,
}),
Brick: BuildingMaterial.create({
name: 'Brick',
price: 0,
thermalConductivity: 0.6,
thickness: 0.2,
}),
WindowGlass: BuildingMaterial.create({
name: 'Window Glass',
price: 150,
thermalConductivity: 0.8,
thickness: 0.004,
}),
Argon: BuildingMaterial.create({
name: 'Argon',
price: 0,
thermalConductivity: 0.018,
thickness: 0.006,
}),
Wood: BuildingMaterial.create({
name: 'Wood',
price: 0,
thermalConductivity: 0.08,
thickness: 0.2,
}),
} as const;
64 changes: 64 additions & 0 deletions src/config/houseInsulations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { UnionOfConst } from '@graasp/sdk';

import { BuildingMaterial } from '@/models/BuildingMaterial';
import { HouseComponent } from '@/types/houseComponent';
import { NonEmptyArray } from '@/types/utils';

import { BUILDING_MATERIALS } from './buildingMaterials';

export const HouseInsulationPerComponent = {
[HouseComponent.Wall]: {
Brick: 'Brick',
Aerogel: 'Aerogel',
Fiberglass: 'Fiberglass',
XPSFoam: 'XPSFoam',
MineralWool: 'MineralWool',
},
[HouseComponent.Door]: {
Wood: 'Wood',
},
[HouseComponent.Window]: {
SinglePane: 'SinglePane',
DoublePane: 'DoublePane',
TriplePane: 'TriplePane',
},
} as const;

export type HouseInsulation =
| UnionOfConst<(typeof HouseInsulationPerComponent)[HouseComponent.Wall]>
| UnionOfConst<(typeof HouseInsulationPerComponent)[HouseComponent.Door]>
| UnionOfConst<(typeof HouseInsulationPerComponent)[HouseComponent.Window]>;

export const HOUSE_INSULATIONS: {
[houseComponent in HouseComponent]: {
[componentInsulationName in keyof (typeof HouseInsulationPerComponent)[houseComponent]]: NonEmptyArray<BuildingMaterial>;
};
} = {
[HouseComponent.Wall]: {
Brick: [BUILDING_MATERIALS.Brick],
Aerogel: [BUILDING_MATERIALS.Brick, BUILDING_MATERIALS.Aerogel],
Fiberglass: [BUILDING_MATERIALS.Brick, BUILDING_MATERIALS.FiberGlass],
XPSFoam: [BUILDING_MATERIALS.Brick, BUILDING_MATERIALS.XPSFoam],
MineralWool: [BUILDING_MATERIALS.Brick, BUILDING_MATERIALS.MineralWool],
},

[HouseComponent.Door]: {
Wood: [BUILDING_MATERIALS.Wood.from({ thickness: 0.1 })],
},

[HouseComponent.Window]: {
SinglePane: [BUILDING_MATERIALS.WindowGlass],
DoublePane: [
BUILDING_MATERIALS.WindowGlass,
BUILDING_MATERIALS.Argon,
BUILDING_MATERIALS.WindowGlass,
],
TriplePane: [
BUILDING_MATERIALS.WindowGlass,
BUILDING_MATERIALS.Argon,
BUILDING_MATERIALS.WindowGlass,
BUILDING_MATERIALS.Argon,
BUILDING_MATERIALS.WindowGlass,
],
},
} as const;
46 changes: 20 additions & 26 deletions src/config/simulation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Material } from '@/types/material';
import { HouseComponentInsulation } from '@/types/houseComponentInsulation';
import { TimeUnit } from '@/types/time';
import { NonEmptyArray } from '@/types/utils';

import {
HOUSE_INSULATIONS,
HouseInsulationPerComponent,
} from './houseInsulations';

export const SIMULATION_FRAME_MS = 150;
export const SIMULATION_SLIDING_WINDOW = { window: 2, unit: TimeUnit.Days };
Expand All @@ -11,29 +15,19 @@ export const SIMULATION_CSV_FILE = {

export const SIMULATION_INDOOR_TEMPERATURE_CELCIUS = 22;
export const SIMULATION_PRICE_KWH = 0.22;
export const AEROGEL_MATERIAL: Material = {
price: 0,
thermalConductivity: 0.021,
thickness: 0.25,
};
export const SINGLE_WINDOW_PANE_MATERIAL: Material = {
price: 0,
thermalConductivity: 0.8,
thickness: 0.005,

export const SIMULATION_DEFAULT_WALL_COMPONENT_INSULATION: Pick<
HouseComponentInsulation,
'insulationName' | 'buildingMaterials'
> = {
insulationName: HouseInsulationPerComponent.Wall.Aerogel,
buildingMaterials: HOUSE_INSULATIONS.Wall.Aerogel,
};
export const DOUBLE_WINDOW_PANE_MATERIAL: NonEmptyArray<Material> = [
SINGLE_WINDOW_PANE_MATERIAL,
// Air
{
price: 0,
thermalConductivity: 0.024,
thickness: 0.005,
},
SINGLE_WINDOW_PANE_MATERIAL,
];

export const SIMULATION_DEFAULT_WALL_MATERIALS: NonEmptyArray<Material> = [
AEROGEL_MATERIAL,
];
export const SIMULATION_DEFAULT_WINDOW_MATERIALS: NonEmptyArray<Material> =
DOUBLE_WINDOW_PANE_MATERIAL;
export const SIMULATION_DEFAULT_WINDOW_COMPONENT_INSULATION: Pick<
HouseComponentInsulation,
'insulationName' | 'buildingMaterials'
> = {
insulationName: HouseInsulationPerComponent.Window.DoublePane,
buildingMaterials: HOUSE_INSULATIONS.Window.DoublePane,
};
Loading

0 comments on commit a8bd1df

Please sign in to comment.