import type { Grain } from './grain-types' export { Grain } from './grain-types' export function coutElec(p: Grain.SimulationCommunaute, N: number) { let cout = 0 for (let i = 0; i < N; i++) { cout += p.coutElec * Math.pow(1 + p.inflationElec / 100, i) * consoMoyenneFoyer(p, i) } return cout } export function coutElecAuto(p: Grain.SimulationCommunaute, N: number) { let cout = 0 for (let i = 0; i < N; i++) { cout += (tarifLocal(p, i) * consoMoyenneFoyer(p, i) * p.autoprod) / 100 + (p.coutElec * Math.pow(1 + p.inflationElec / 100, i) * consoMoyenneFoyer(p, i) * (100 - p.autoprod)) / 100 } return cout } export function tarifLocal(p: Grain.SimulationCommunaute, i: number) { return p.prix * Math.pow(1 + p.inflation / 100, i) } export function productionAnnuelle(p: Grain.SimulationCommunaute, i: number) { return p.productible * p.puissance * Math.pow(1 - p.degradation / 100, i) } export function consoMoyenneFoyer(p: Grain.SimulationCommunaute, i: number) { return Math.min(p.consoMoyenneFoyer, productionAnnuelle(p, i) / p.autoprod) }