mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- Initialize git repository - Add comprehensive .gitignore for Go projects - Install golangci-lint v2.6.0 (latest v2) globally - Configure .golangci.yml with appropriate linters and formatters - Fix all formatting issues (gofmt) - Fix all errcheck issues (unchecked errors) - Adjust complexity threshold for validation functions - All checks passing: build, test, vet, lint
40 lines
1.5 KiB
Go
40 lines
1.5 KiB
Go
package impact
|
||
|
||
import (
|
||
"github.com/damirmukimov/city_resource_graph/models/customer"
|
||
"github.com/damirmukimov/city_resource_graph/models/params"
|
||
)
|
||
|
||
// ImpactMetrics represents environmental impact metrics for a given year.
|
||
type ImpactMetrics struct {
|
||
CO2Avoided float64 `json:"co2_avoided"` // CO₂ avoided (t CO₂/year)
|
||
WaterReused float64 `json:"water_reused"` // Water reused (m³/year)
|
||
WasteDiverted float64 `json:"waste_diverted"` // Waste diverted from landfill (t/year)
|
||
}
|
||
|
||
// CalculateImpact computes environmental impact metrics for a given year.
|
||
func CalculateImpact(year int, custMetrics customer.CustomerMetrics, p *params.Params) ImpactMetrics {
|
||
ip := p.Impact
|
||
|
||
// CO₂ avoided from heat recovery
|
||
// Formula: CO₂ = Heat_MWh × Grid_Factor × HX_Eff × Utilization
|
||
heatMWh := ip.HeatMWh.GetYear(year)
|
||
co2Avoided := heatMWh * ip.GridFactor * ip.HXEff * ip.Utilization
|
||
|
||
// Water reused
|
||
// Formula: Water_Reused = Total_Orgs × Water_Per_Org × Reuse_Rate
|
||
waterReuseRate := ip.WaterReuseRate.GetYear(year)
|
||
waterReused := float64(custMetrics.TotalOrgs) * ip.WaterPerOrg * waterReuseRate
|
||
|
||
// Waste diverted
|
||
// Formula: Waste_Diverted = Total_Orgs × Waste_Per_Org × Diversion_Rate
|
||
wasteDiversionRate := ip.WasteDiversionRate.GetYear(year)
|
||
wasteDiverted := float64(custMetrics.TotalOrgs) * ip.WastePerOrg * wasteDiversionRate
|
||
|
||
return ImpactMetrics{
|
||
CO2Avoided: co2Avoided,
|
||
WaterReused: waterReused,
|
||
WasteDiverted: wasteDiverted,
|
||
}
|
||
}
|