forked from ShadowTheAge/yafc
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ain. (#273) When used as inputs to be boiled, fluids with multiple temperatures were treated as if they were already at their maximum temperature. In addition to the new test, I also confirmed that the boiler mechanics for pY showed the same number of buildings for each input temperature here as they did in 0.8.1.
- Loading branch information
Showing
5 changed files
with
186 additions
and
1 deletion.
There are no files selected for viewing
125 changes: 125 additions & 0 deletions
125
Yafc.Model.Tests/Model/RecipeParametersTests.FluidBoilingRecipes_HaveCorrectConsumption.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
data = { | ||
raw = { | ||
recipe = { | ||
-- Recipes so Yafc will split water into the required temperatures | ||
cold_water = { | ||
type = "recipe", | ||
name = "cold_water", | ||
category = "oil-processing", | ||
energy_required = 5, | ||
results = { | ||
{ | ||
type = "fluid", | ||
name = "water", | ||
amount = 50, | ||
temperature = 15, | ||
}, | ||
}, | ||
}, | ||
warm_water = { | ||
type = "recipe", | ||
name = "warm_water", | ||
category = "oil-processing", | ||
energy_required = 5, | ||
results = { | ||
{ | ||
type = "fluid", | ||
name = "water", | ||
amount = 50, | ||
temperature = 50, | ||
}, | ||
}, | ||
}, | ||
hot_water = { | ||
type = "recipe", | ||
name = "hot_water", | ||
category = "oil-processing", | ||
energy_required = 5, | ||
results = { | ||
{ | ||
type = "fluid", | ||
name = "water", | ||
amount = 50, | ||
temperature = 90, | ||
}, | ||
}, | ||
}, | ||
}, | ||
item = { | ||
coal = { | ||
type = "item", | ||
name = "coal", | ||
fuel_category = "chemical", | ||
fuel_value = "4MJ", | ||
}, | ||
}, | ||
fluid = { | ||
water = { | ||
type = "fluid", | ||
name = "water", | ||
default_temperature = 15, | ||
max_temperature = 1000, | ||
heat_capacity = "0.2KJ", | ||
icon = "", | ||
}, | ||
steam = { | ||
type = "fluid", | ||
name = "steam", | ||
default_temperature = 15, | ||
max_temperature = 1000, | ||
heat_capacity = "0.2KJ", | ||
gas_temperature = 15, | ||
auto_barrel = False, | ||
icon = "", | ||
}, | ||
}, | ||
boiler = { | ||
boiler = { | ||
type = "boiler", | ||
name = "boiler", | ||
mode = "output-to-separate-pipe", | ||
target_temperature = 165, | ||
fluid_box = { | ||
filter = "water", | ||
}, | ||
output_fluid_box = { | ||
filter = "steam", | ||
}, | ||
energy_consumption = "1.8MW", | ||
energy_source = { | ||
type = "burner", | ||
fuel_category = "chemical", | ||
}, | ||
}, | ||
["heat-exchanger"] = { | ||
type = "boiler", | ||
name = "heat-exchanger", | ||
mode = "output-to-separate-pipe", | ||
target_temperature = 500, | ||
fluid_box = { | ||
filter = "water", | ||
}, | ||
output_fluid_box = { | ||
filter = "steam", | ||
}, | ||
energy_consumption = "10MW", | ||
energy_source = { | ||
type = "heat", | ||
max_temperature = 1000, | ||
specific_heat = "1MJ", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
defines.prototypes = { | ||
entity = { | ||
boiler = 0, | ||
}, | ||
item = { | ||
item = 0, | ||
}, | ||
fluid = { | ||
fluid = 0, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Google.OrTools.ConstraintSolver; | ||
using Xunit; | ||
|
||
namespace Yafc.Model.Tests.Model; | ||
|
||
[Collection("LuaDependentTests")] | ||
public class RecipeParametersTests { | ||
[Fact] | ||
public void FluidBoilingRecipes_HaveCorrectConsumption() { | ||
Project project = LuaDependentTestHelper.GetProjectForLua(); | ||
|
||
ProjectPage page = new(project, typeof(ProductionTable)); | ||
project.pages.Add(page); | ||
ProductionTable table = (ProductionTable)page.content; | ||
table.AddRecipe(Database.recipes.all.Single(r => r.name == "boiler.boiler.steam"), DataUtils.DeterministicComparer); | ||
table.AddRecipe(Database.recipes.all.Single(r => r.name == "boiler.heat-exchanger.steam"), DataUtils.DeterministicComparer); | ||
|
||
List<Fluid> water = Database.fluidVariants["Fluid.water"]; | ||
|
||
RecipeRow boiler = table.recipes[0]; | ||
RecipeRow heatExchanger = table.recipes[1]; | ||
boiler.fixedBuildings = 1; | ||
heatExchanger.fixedBuildings = 1; | ||
table.Solve((ProjectPage)table.owner).Wait(); // Initial Solve to set RecipeRow.Ingredients | ||
|
||
for (int i = 0; i < 3; i++) { | ||
boiler.ChangeVariant(boiler.Ingredients.Single().Goods, water[i]); | ||
heatExchanger.ChangeVariant(boiler.Ingredients.Single().Goods, water[i]); | ||
|
||
table.Solve((ProjectPage)table.owner).Wait(); | ||
|
||
// boil 60, 78.26, 120 water per second from 15, 50, 90° to 165° | ||
float expectedBoilerAmount = 1800 / .2f / (165 - water[i].temperature); | ||
// boil 103.09, 111.11, 121.95 water per second from 15, 50, 90° to 500° | ||
float expectedHeatExchangerAmount = 10000 / .2f / (500 - water[i].temperature); | ||
// Equation is boiler power (KW) / heat capacity (KJ/unit°C) / temperature change (°C) => unit/s | ||
|
||
Assert.Equal(.45f, boiler.FuelInformation.Amount, .45f * .0001f); // Always .45 coal per second | ||
Assert.Equal(expectedBoilerAmount, boiler.Ingredients.Single().Amount, expectedBoilerAmount * .0001f); | ||
Assert.Equal(expectedBoilerAmount, boiler.Products.Single().Amount, expectedBoilerAmount * .0001f); | ||
|
||
Assert.Equal(10, heatExchanger.FuelInformation.Amount); // Always 10 MW heat | ||
Assert.Equal(expectedHeatExchangerAmount, heatExchanger.Ingredients.Single().Amount, expectedHeatExchangerAmount * .0001f); | ||
Assert.Equal(expectedHeatExchangerAmount, heatExchanger.Products.Single().Amount, expectedHeatExchangerAmount * .0001f); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters