feat: Adds cooling interpolation tests.

This commit is contained in:
2025-03-13 09:10:52 -04:00
parent ec58ca6364
commit c23e4c5f61
7 changed files with 287 additions and 112 deletions

View File

@@ -6,6 +6,138 @@ import Testing
@Suite("ManualSTests")
struct ManualSTests {
@Test
func coolingInterpolation_noInterpolation() async throws {
try await withDependencies {
$0.manualS = .liveValue
} operation: {
@Dependency(\.manualS) var manualS
let response = try await manualS.coolingInterpolation(.init(
summerDesignInfo: .mock,
coolingLoad: .mockCoolingLoad,
systemType: .airToAir(type: .airConditioner, compressor: .singleSpeed, climate: .mildWinterOrLatentLoad),
interpolation: .noInterpolation(
.init(
airflow: 800,
capacity: .init(
dryBulbTemperature: 75,
wetBulbTemperature: 63,
outdoorTemperature: 90,
totalCapacity: 22600,
sensibleCapacity: 16850
)
),
nil
)
))
#expect(response.failed)
#expect(response.failures == ["Oversizing total failure."])
#expect(response.interpolatedCapacity == .init(total: 22600, sensible: 16850))
#expect(response.excessLatent == 886)
#expect(response.finalCapacityAtDesign == .init(total: 22600, sensible: 17736))
#expect(response.capacityAsPercentOfLoad == .init(total: 126, sensible: 127, latent: 122))
}
}
@Test
func coolingInterpolation_oneWayIndoor() async throws {
try await withDependencies {
$0.manualS = .liveValue
} operation: {
@Dependency(\.manualS) var manualS
let response = try await manualS.coolingInterpolation(.init(
summerDesignInfo: .mock,
coolingLoad: .mockCoolingLoad,
systemType: .airToAir(type: .airConditioner, compressor: .singleSpeed, climate: .mildWinterOrLatentLoad),
interpolation: .oneWayIndoor(.init(
airflow: 800,
outdoorTemperature: 95,
capacities: .init(
aboveDewpoint: .init(wetBulb: 67, totalCapacity: 24828, sensibleCapacity: 15937),
belowDewpoint: .init(wetBulb: 62, totalCapacity: 23046, sensibleCapacity: 19078)
)
))
))
#expect(response.failed)
#expect(response.failures == ["Oversizing total failure."])
#expect(response.interpolatedCapacity == .init(total: 23402, sensible: 18450))
#expect(response.excessLatent == 487)
#expect(response.finalCapacityAtDesign == .init(total: 23402, sensible: 18937))
#expect(response.capacityAsPercentOfLoad == .init(total: 130, sensible: 136, latent: 112))
}
}
@Test
func coolingInterpolation_oneWayOutdoor() async throws {
try await withDependencies {
$0.manualS = .liveValue
} operation: {
@Dependency(\.manualS) var manualS
let response = try await manualS.coolingInterpolation(.init(
summerDesignInfo: .mock,
coolingLoad: .mockCoolingLoad,
systemType: .airToAir(type: .airConditioner, compressor: .singleSpeed, climate: .mildWinterOrLatentLoad),
interpolation: .oneWayOutdoor(.init(
airflow: 800,
wetBulb: 63,
capacities: .init(
aboveOutdoor: .init(outdoorTemperature: 95, totalCapacity: 22000, sensibleCapacity: 16600),
belowOutdoor: .init(outdoorTemperature: 85, totalCapacity: 23200, sensibleCapacity: 17100)
)
))
))
#expect(response.failed)
#expect(response.failures == ["Oversizing total failure."])
#expect(response.interpolatedCapacity == .init(total: 22600, sensible: 16850))
#expect(response.excessLatent == 886)
#expect(response.finalCapacityAtDesign == .init(total: 22600, sensible: 17736))
#expect(response.capacityAsPercentOfLoad == .init(total: 126, sensible: 127, latent: 122))
}
}
@Test
func coolingInterpolation_twoWay() async throws {
try await withDependencies {
$0.manualS = .liveValue
} operation: {
@Dependency(\.manualS) var manualS
let response = try await manualS.coolingInterpolation(.init(
summerDesignInfo: .mock,
coolingLoad: .mockCoolingLoad,
systemType: .airToAir(type: .airConditioner, compressor: .singleSpeed, climate: .mildWinterOrLatentLoad),
interpolation: .twoWay(.init(
airflow: 800,
capacities: .init(
above: .init(
outdoorTemperature: 95,
aboveDewPoint: .init(wetBulb: 67, totalCapacity: 24828, sensibleCapacity: 15937),
belowDewPoint: .init(wetBulb: 62, totalCapacity: 23046, sensibleCapacity: 19078)
),
below: .init(
outdoorTemperature: 85,
aboveDewPoint: .init(wetBulb: 67, totalCapacity: 25986, sensibleCapacity: 16330),
belowDewPoint: .init(wetBulb: 62, totalCapacity: 24029, sensibleCapacity: 19605)
)
)
))
))
#expect(response.failed)
#expect(response.failures == ["Oversizing total failure."])
#expect(response.interpolatedCapacity == .init(total: 23915, sensible: 18700))
#expect(response.excessLatent == 618)
#expect(response.finalCapacityAtDesign == .init(total: 23915, sensible: 19318))
#expect(response.capacityAsPercentOfLoad == .init(total: 133, sensible: 139, latent: 115))
}
}
@Test
func balancePoint() async throws {
try await withDependencies {
@@ -52,7 +184,7 @@ struct ManualSTests {
let limits = try await manualS.sizingLimits(.init(
systemType: system,
houseLoad: .init(coolingTotal: 17872, coolingSensible: 13894, heating: 49667)
coolingLoad: .init(total: 17872, sensible: 13894)
))
#expect(limits.oversizing.coolingLatent == 150)
@@ -211,3 +343,11 @@ extension SystemType.HeatingOnlyType {
}
}
}
extension Capacity.Cooling {
static let mockCoolingLoad = Self(total: 17872, sensible: 13894)
}
extension DesignInfo.Summer {
static let mock = Self(outdoorTemperature: 90, indoorTemperature: 75, indoorHumidity: 50)
}