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.cout_elec *
Math.pow(1 + p.inflation_elec / 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 +=
((p.prix * Math.pow(1+ p.inflation/100, i)) * consoMoyenneFoyer(p, i) * p.autoprod) / 100 +
(p.cout_elec *
Math.pow(1 + p.inflation_elec / 100, i) *
consoMoyenneFoyer(p, i) *
(100 - p.autoprod)) /
100
}
return cout
}
export function productionAnnuelle(productible: number, puissance: number, degradation: number, i: number) {
return productible * puissance * Math.pow(1 - degradation / 100, i)
}
export function consoMoyenneFoyer(p: Grain.SimulationCommunaute, i: number) {
return Math.min(p.conso_moyenne_foyer, productionAnnuelle(p.productible, p.puissance, p.degradation, i) / p.autoprod)
}