Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use input fluid temperature for boilers #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion YAFCmodel/Model/ProductionTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public override async Task<string> Solve(ProjectPage page)
for (var i = 0; i < allRecipes.Count; i++)
{
var recipe = allRecipes[i];
recipe.parameters.CalculateParameters(recipe.recipe, recipe.entity, recipe.fuel, recipe);
recipe.parameters.CalculateParameters(recipe.recipe, recipe.entity, recipe.fuel, recipe.variants, recipe);
var variable = solver.MakeNumVar(0f, double.PositiveInfinity, recipe.recipe.name);
if (recipe.fixedBuildings > 0f)
{
Expand Down
11 changes: 10 additions & 1 deletion YAFCmodel/Model/RecipeParameters.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;

namespace YAFC.Model
{
Expand Down Expand Up @@ -56,7 +57,7 @@ public void Clear()
modules = default;
}

public void CalculateParameters(Recipe recipe, EntityCrafter entity, Goods fuel, IModuleFiller moduleFiller)
public void CalculateParameters(Recipe recipe, EntityCrafter entity, Goods fuel, HashSet<FactorioObject> variants, IModuleFiller moduleFiller)
{
warningFlags = 0;
if (entity == null)
Expand Down Expand Up @@ -135,6 +136,14 @@ public void CalculateParameters(Recipe recipe, EntityCrafter entity, Goods fuel,
if (fluid != null)
{
float inputTemperature = fluid.temperature;
foreach (var variant in variants)
{
if (variant is Fluid fluidVariant && fluidVariant.originalName == fluid.originalName)
{
inputTemperature = fluidVariant.temperature;
}
}

var outputTemp = recipe.products[0].goods.fluid.temperature;
var deltaTemp = (outputTemp - inputTemperature);
var energyPerUnitOfFluid = deltaTemp * fluid.heatCapacity;
Expand Down