feat: Adds furnace heating interpolations.
All checks were successful
CI / Ubuntu (push) Successful in 11m23s
All checks were successful
CI / Ubuntu (push) Successful in 11m23s
This commit is contained in:
@@ -129,14 +129,6 @@ private extension SizingLimits.Response {
|
||||
}
|
||||
}
|
||||
|
||||
private func normalizePercentage(
|
||||
_ lhs: Int,
|
||||
_ rhs: Int
|
||||
) -> Int {
|
||||
let value = Double(lhs) / Double(rhs)
|
||||
return Int((value * 1000).rounded() / 10.0)
|
||||
}
|
||||
|
||||
private extension CoolingInterpolation.InterpolationRequest {
|
||||
|
||||
func interpolatedCapacity(outdoorDesignTemperature: Int) async -> Capacity.Cooling {
|
||||
|
||||
55
Sources/ManualS/Internal/FurnaceInterpolation.swift
Normal file
55
Sources/ManualS/Internal/FurnaceInterpolation.swift
Normal file
@@ -0,0 +1,55 @@
|
||||
import Models
|
||||
import Validations
|
||||
|
||||
extension FurnaceInterpolation.Request {
|
||||
private static let undersizingLimit = 90
|
||||
private static let oversizingLimit = 140
|
||||
|
||||
func respond() async throws -> FurnaceInterpolation.Response {
|
||||
try await validate()
|
||||
let altitudeDerating = try await altitudeDerating()
|
||||
let outputCapacity = Int(
|
||||
(Double(inputRating) * (altitudeDerating ?? 1.0))
|
||||
* (afue / 100)
|
||||
)
|
||||
let capacityAsPercentOfLoad = normalizePercentage(outputCapacity, heatLoss)
|
||||
|
||||
var failures = [String]()
|
||||
if capacityAsPercentOfLoad < Self.undersizingLimit {
|
||||
failures.append("Undersizing failure.")
|
||||
}
|
||||
if capacityAsPercentOfLoad > Self.oversizingLimit {
|
||||
failures.append("Oversizing failure.")
|
||||
}
|
||||
|
||||
return .init(
|
||||
failures: failures.isEmpty ? nil : failures,
|
||||
altitudeAdjustmentMultiplier: altitudeDerating,
|
||||
capacityAsPercentOfLoad: capacityAsPercentOfLoad,
|
||||
oversizingLimit: Self.oversizingLimit,
|
||||
undersizingLimit: Self.undersizingLimit,
|
||||
outputCapacity: outputCapacity
|
||||
)
|
||||
}
|
||||
|
||||
func altitudeDerating() async throws -> Double? {
|
||||
guard let elevation else { return nil }
|
||||
let response = try await Derating.Request(
|
||||
elevation: elevation,
|
||||
systemType: .heatingOnly(type: .furnace)
|
||||
).respond()
|
||||
return response.heating
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension FurnaceInterpolation.Request: AsyncValidatable {
|
||||
public var body: some AsyncValidation<Self> {
|
||||
AsyncValidator.accumulating {
|
||||
AsyncValidator.greaterThan(\.heatLoss, 0)
|
||||
AsyncValidator.greaterThan(\.inputRating, 0)
|
||||
AsyncValidator.greaterThan(\.afue, 0)
|
||||
AsyncValidator.lessThan(\.afue, 100)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user