Skip to content

Commit

Permalink
feat: remove code complexity (#113)
Browse files Browse the repository at this point in the history
* feat(refactor): simplify heatloss and season

* feat(refactor): define simulation duration in years

* feat(refactor): remove measurement frequency to have one temperature per day

* feat(refactor): regroup simulation context properties by domain
  • Loading branch information
ReidyT authored Dec 19, 2024
1 parent 21bbae5 commit e94c3f0
Show file tree
Hide file tree
Showing 27 changed files with 272 additions and 446 deletions.
12 changes: 2 additions & 10 deletions src/config/simulation.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import { HouseComponentInsulation } from '@/types/houseComponentInsulation';
import { TimeUnit } from '@/types/time';

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

export const SIMULATION_FRAME_MS = 150;
export const SIMULATION_SLIDING_WINDOW = { window: 1, unit: TimeUnit.Days };
export const SIMULATION_CSV_FILES = {
1: {
path: 'temperatures/predictions_1_year.csv',
measurementFrequency: TimeUnit.Days,
},
25: {
path: 'temperatures/predictions_25_year.csv',
measurementFrequency: TimeUnit.Days,
},
1: 'temperatures/predictions_1_year.csv',
25: 'temperatures/predictions_25_year.csv',
} as const;

export const SIMULATION_INDOOR_TEMPERATURE_CELCIUS = {
Expand Down
7 changes: 3 additions & 4 deletions src/context/SeasonContext.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ReactNode, createContext, useContext, useMemo } from 'react';

import { Season, Seasons } from '@/types/seasons';
import { getMostPresentSeason } from '@/utils/seasons';
import { getSeason } from '@/utils/seasons';

import { useSimulation } from './SimulationContext';

Expand All @@ -18,9 +18,8 @@ type Props = {
};

export const SeasonProvider = ({ children }: Props): ReactNode => {
const { date } = useSimulation();
// TODO: juste use the date...
const season = getMostPresentSeason(date, date);
const { date } = useSimulation('simulation');
const season = getSeason(date);

const contextValue = useMemo(
() => ({
Expand Down
Loading

0 comments on commit e94c3f0

Please sign in to comment.