It seems the Heat Transfer equations I'm using are a bit stiff.

Adjust some paramaters some to improve how well we deal with this.
This commit is contained in:
Ben Spiers 2015-01-09 02:50:18 +00:00
parent aa91fa87a6
commit b8b49db104
8 changed files with 152 additions and 54 deletions

View file

@ -33,6 +33,7 @@ import mekanism.common.Tier.FactoryTier;
import mekanism.common.base.IFactory.RecipeType;
import mekanism.common.base.IModule;
import mekanism.common.content.boiler.BoilerCache;
import mekanism.common.content.boiler.BoilerManager;
import mekanism.common.content.boiler.SynchronizedBoilerData;
import mekanism.common.content.matrix.MatrixCache;
import mekanism.common.content.matrix.SynchronizedMatrixData;
@ -162,7 +163,7 @@ public class Mekanism
public static MultiblockManager<SynchronizedTankData> tankManager = new MultiblockManager<SynchronizedTankData>("dynamicTank", TankCache.class);
public static MultiblockManager<SynchronizedMatrixData> matrixManager = new MultiblockManager<SynchronizedMatrixData>("energizedInductionMatrix", MatrixCache.class);
public static MultiblockManager<SynchronizedTurbineData> turbineManager = new MultiblockManager<SynchronizedTurbineData>("industrialTurbine", TurbineCache.class);
public static MultiblockManager<SynchronizedBoilerData> boilerManager = new MultiblockManager<SynchronizedBoilerData>("thermoelectricBoiler", BoilerCache.class);
public static MultiblockManager<SynchronizedBoilerData> boilerManager = new BoilerManager("thermoelectricBoiler");
/** Mekanism creative tab */
public static CreativeTabMekanism tabMekanism = new CreativeTabMekanism();

View file

@ -1,5 +1,6 @@
package mekanism.common.content.boiler;
import mekanism.api.Coord4D;
import mekanism.common.content.tank.SynchronizedTankData;
import mekanism.common.multiblock.MultiblockCache;
import mekanism.common.util.FluidContainerUtils.ContainerEditMode;
@ -7,9 +8,12 @@ import mekanism.common.util.FluidContainerUtils.ContainerEditMode;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.Constants.NBT;
import net.minecraftforge.fluids.FluidStack;
import java.util.HashMap;
public class BoilerCache extends MultiblockCache<SynchronizedBoilerData>
{
public ItemStack[] inventory = new ItemStack[2];

View file

@ -0,0 +1,96 @@
package mekanism.common.content.boiler;
import mekanism.api.Coord4D;
import mekanism.common.multiblock.MultiblockCache;
import mekanism.common.multiblock.MultiblockManager;
import mekanism.common.tile.TileEntityBoiler;
import mekanism.common.tile.TileEntityMultiblock;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
/**
* Created by ben on 09/01/15.
*/
public class BoilerManager extends MultiblockManager<SynchronizedBoilerData>
{
public BoilerManager(String s)
{
super(s, BoilerCache.class);
}
public void tickSelf(World world)
{
ArrayList<Integer> idsToKill = new ArrayList<Integer>();
HashMap<Integer, HashSet<Coord4D>> tilesToKill = new HashMap<Integer, HashSet<Coord4D>>();
for(Map.Entry<Integer, MultiblockCache<SynchronizedBoilerData>> entry : inventories.entrySet())
{
int inventoryID = entry.getKey();
HashSet<TileEntityBoiler> boilers = new HashSet<TileEntityBoiler>();
for(Coord4D obj : entry.getValue().locations)
{
if(obj.dimensionId == world.provider.dimensionId && obj.exists(world))
{
TileEntity tileEntity = obj.getTileEntity(world);
if(!(tileEntity instanceof TileEntityMultiblock) || ((TileEntityMultiblock)tileEntity).getManager() != this || (getStructureId(((TileEntityMultiblock<?>)tileEntity)) != -1 && getStructureId(((TileEntityMultiblock)tileEntity)) != inventoryID))
{
if(!tilesToKill.containsKey(inventoryID))
{
tilesToKill.put(inventoryID, new HashSet<Coord4D>());
}
tilesToKill.get(inventoryID).add(obj);
}
else if(tileEntity instanceof TileEntityBoiler)
{
((TileEntityBoiler)tileEntity).simulateHeat();
boilers.add((TileEntityBoiler) tileEntity);
}
}
}
if(!boilers.isEmpty())
{
SynchronizedBoilerData data = boilers.iterator().next().getSynchronizedData();
if(data != null)
{
boilers.iterator().next().getSynchronizedData().applyTemperatureChange();
}
for (TileEntityBoiler boiler : boilers)
{
boiler.applyTemperatureChange();
}
}
if(entry.getValue().locations.isEmpty())
{
idsToKill.add(inventoryID);
}
}
for(Map.Entry<Integer, HashSet<Coord4D>> entry : tilesToKill.entrySet())
{
for(Coord4D obj : entry.getValue())
{
inventories.get(entry.getKey()).locations.remove(obj);
dataHandler.markDirty();
}
}
for(int inventoryID : idsToKill)
{
inventories.remove(inventoryID);
dataHandler.markDirty();
}
}
}

View file

@ -104,7 +104,7 @@ public class BoilerUpdateProtocol extends UpdateProtocol<SynchronizedBoilerData>
data.location = obj;
data.side = getSide(obj, origX+xmin, origX+xmax, origY+ymin, origY+ymax, origZ+zmin, origZ+zmax);
((SynchronizedBoilerData)structure).valves.add(data);
structure.valves.add(data);
}
}
}

View file

@ -23,7 +23,7 @@ public class SynchronizedBoilerData extends SynchronizedData<SynchronizedBoilerD
public double heatToAbsorb;
public double heatCapacity = 100;
public double heatCapacity = 0.000001;
public double enthalpyOfVaporization = 10;
@ -48,7 +48,7 @@ public class SynchronizedBoilerData extends SynchronizedData<SynchronizedBoilerD
@Override
public double getInverseConductionCoefficient()
{
return 100;
return 1;
}
@Override
@ -76,7 +76,7 @@ public class SynchronizedBoilerData extends SynchronizedData<SynchronizedBoilerD
if(temperature < 100 + IHeatTransfer.AMBIENT_TEMP)
{
double temperatureDeficit = 100 + IHeatTransfer.AMBIENT_TEMP - temperature;
double heatNeeded = temperatureDeficit * volume * heatCapacity * 16;
double heatNeeded = temperatureDeficit * volume * heatCapacity * 16000;
double heatProvided = Math.min(heatToAbsorb, heatNeeded);
heatToAbsorb -= heatProvided;
temperature += heatProvided / (volume * heatCapacity * 16);
@ -97,7 +97,7 @@ public class SynchronizedBoilerData extends SynchronizedData<SynchronizedBoilerD
heatToAbsorb -= amountToBoil * enthalpyOfVaporization;
}
heatToAbsorb *= 0.2;
heatToAbsorb *= 0.8;
return temperature;
}

View file

@ -9,7 +9,6 @@ import mekanism.common.MekanismBlocks;
import mekanism.common.content.tank.SynchronizedTankData.ValveData;
import mekanism.common.multiblock.MultiblockCache;
import mekanism.common.multiblock.MultiblockManager;
import mekanism.common.multiblock.SynchronizedData;
import mekanism.common.multiblock.UpdateProtocol;
import mekanism.common.tile.TileEntityDynamicTank;
import mekanism.common.tile.TileEntityDynamicValve;
@ -74,14 +73,14 @@ public class TankUpdateProtocol extends UpdateProtocol<SynchronizedTankData>
@Override
protected void onFormed()
{
if(((SynchronizedTankData)structureFound).fluidStored != null)
if(structureFound.fluidStored != null)
{
((SynchronizedTankData)structureFound).fluidStored.amount = Math.min(((SynchronizedTankData)structureFound).fluidStored.amount, structureFound.volume*FLUID_PER_TANK);
structureFound.fluidStored.amount = Math.min(structureFound.fluidStored.amount, structureFound.volume*FLUID_PER_TANK);
}
}
@Override
protected void onStructureCreated(SynchronizedData<SynchronizedTankData> structure, int origX, int origY, int origZ, int xmin, int xmax, int ymin, int ymax, int zmin, int zmax)
protected void onStructureCreated(SynchronizedTankData structure, int origX, int origY, int origZ, int xmin, int xmax, int ymin, int ymax, int zmin, int zmax)
{
for(Coord4D obj : structure.locations)
{
@ -91,7 +90,7 @@ public class TankUpdateProtocol extends UpdateProtocol<SynchronizedTankData>
data.location = obj;
data.side = getSide(obj, origX+xmin, origX+xmax, origY+ymin, origY+ymax, origZ+zmin, origZ+zmax);
((SynchronizedTankData)structure).valves.add(data);
structure.valves.add(data);
}
}
}

View file

@ -140,21 +140,27 @@ public class MultiblockManager<T extends SynchronizedData<T>>
}
for(MultiblockManager manager : managers)
{
manager.tickSelf(world);
}
}
public void tickSelf(World world)
{
ArrayList<Integer> idsToKill = new ArrayList<Integer>();
HashMap<Integer, HashSet<Coord4D>> tilesToKill = new HashMap<Integer, HashSet<Coord4D>>();
for(Map.Entry<Integer, MultiblockCache> entry : ((Map<Integer, MultiblockCache>)manager.inventories).entrySet())
for(Map.Entry<Integer, MultiblockCache<T>> entry : inventories.entrySet())
{
int inventoryID = entry.getKey();
for(Coord4D obj : (Set<Coord4D>)entry.getValue().locations)
for(Coord4D obj : entry.getValue().locations)
{
if(obj.dimensionId == world.provider.dimensionId && obj.exists(world))
{
TileEntity tileEntity = obj.getTileEntity(world);
if(!(tileEntity instanceof TileEntityMultiblock) || ((TileEntityMultiblock)tileEntity).getManager() != manager || (getStructureId(((TileEntityMultiblock<?>)tileEntity)) != -1 && getStructureId(((TileEntityMultiblock)tileEntity)) != inventoryID))
if(!(tileEntity instanceof TileEntityMultiblock) || ((TileEntityMultiblock)tileEntity).getManager() != this || (getStructureId(((TileEntityMultiblock<?>)tileEntity)) != -1 && getStructureId(((TileEntityMultiblock)tileEntity)) != inventoryID))
{
if(!tilesToKill.containsKey(inventoryID))
{
@ -176,16 +182,15 @@ public class MultiblockManager<T extends SynchronizedData<T>>
{
for(Coord4D obj : entry.getValue())
{
((Map<Integer, MultiblockCache>)manager.inventories).get(entry.getKey()).locations.remove(obj);
manager.dataHandler.markDirty();
inventories.get(entry.getKey()).locations.remove(obj);
dataHandler.markDirty();
}
}
for(int inventoryID : idsToKill)
{
manager.inventories.remove(inventoryID);
manager.dataHandler.markDirty();
}
inventories.remove(inventoryID);
dataHandler.markDirty();
}
}

View file

@ -43,7 +43,7 @@ public class TileEntityBoiler extends TileEntityMultiblock<SynchronizedBoilerDat
public double temperature;
public double heatToAbsorb;
public double invHeatCapacity = 10;
public double invHeatCapacity = 5;
public TileEntityBoiler()
{
@ -110,13 +110,6 @@ public class TileEntityBoiler extends TileEntityMultiblock<SynchronizedBoilerDat
{
manageInventory();
}
simulateHeat();
applyTemperatureChange();
if(structure != null)
{
structure.applyTemperatureChange();
}
}
}
@ -461,13 +454,13 @@ public class TileEntityBoiler extends TileEntityMultiblock<SynchronizedBoilerDat
@Override
public double getInverseConductionCoefficient()
{
return 10;
return 50;
}
@Override
public double getInsulationCoefficient(ForgeDirection side)
{
return 10;
return 50;
}
@Override