turash/models/impact/impact.go
Damir Mukimov 4a2fda96cd
Initial commit: Repository setup with .gitignore, golangci-lint v2.6.0, and code quality checks
- 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
2025-11-01 07:36:22 +01:00

40 lines
1.5 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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,
}
}