Fix things, adjust the algorithm slightly to model the differential equation better.
This commit is contained in:
parent
497997d0e4
commit
16e38fafbe
4 changed files with 27 additions and 13 deletions
|
@ -34,21 +34,26 @@ public class FusionReactor implements IFusionReactor
|
|||
public Set<IReactorBlock> reactorBlocks = new HashSet<IReactorBlock>();
|
||||
public Set<INeutronCapture> neutronCaptors = new HashSet<INeutronCapture>();
|
||||
|
||||
//Current stores of energy
|
||||
//Current stores of temperature
|
||||
public double plasmaTemperature;
|
||||
public double caseTemperature;
|
||||
|
||||
//Last values of temperature
|
||||
public double lastPlasmaTemperature;
|
||||
public double lastCaseTemperature;
|
||||
|
||||
//Reaction characteristics
|
||||
public static double burnTemperature = 1E8;
|
||||
public static double burnRatio = 1;
|
||||
public static double tempPerFuel = 5E6;
|
||||
public static double energyPerFuel = 5E6;
|
||||
public int injectionRate = 0;
|
||||
|
||||
//Thermal characteristics
|
||||
public static double plasmaHeatCapacity = 1;
|
||||
public static double plasmaHeatCapacity = 100;
|
||||
public static double caseHeatCapacity = 1;
|
||||
public static double enthalpyOfVaporization = 10;
|
||||
public static double thermocoupleEfficiency = 0.01;
|
||||
public static double thermocoupleEfficiency = 0.001;
|
||||
public static double steamTransferEfficiency = 0.01;
|
||||
|
||||
//Heat transfer metrics
|
||||
public static double plasmaCaseConductivity = 0.2;
|
||||
|
@ -99,6 +104,9 @@ public class FusionReactor implements IFusionReactor
|
|||
//Perform the heat transfer calculations
|
||||
transferHeat();
|
||||
|
||||
lastPlasmaTemperature = plasmaTemperature;
|
||||
lastCaseTemperature = caseTemperature;
|
||||
|
||||
if(plasmaTemperature > 1E-6 || caseTemperature > 1E-6)
|
||||
{
|
||||
Mekanism.logger.info("Reactor temperatures: Plasma: " + (int) plasmaTemperature + ", Casing: " + (int) caseTemperature);
|
||||
|
@ -125,9 +133,9 @@ public class FusionReactor implements IFusionReactor
|
|||
|
||||
public int burnFuel()
|
||||
{
|
||||
int fuelBurned = (int)min(getFuelTank().getStored(), max(0, plasmaTemperature - burnTemperature)*burnRatio);
|
||||
int fuelBurned = (int)min(getFuelTank().getStored(), max(0, lastPlasmaTemperature - burnTemperature)*burnRatio);
|
||||
getFuelTank().draw(fuelBurned, true);
|
||||
plasmaTemperature += tempPerFuel * fuelBurned;
|
||||
plasmaTemperature += energyPerFuel * fuelBurned / plasmaHeatCapacity;
|
||||
return fuelBurned;
|
||||
}
|
||||
|
||||
|
@ -149,29 +157,29 @@ public class FusionReactor implements IFusionReactor
|
|||
public void transferHeat()
|
||||
{
|
||||
//Transfer from plasma to casing
|
||||
double plasmaCaseHeat = plasmaCaseConductivity * (plasmaTemperature - caseTemperature);
|
||||
double plasmaCaseHeat = plasmaCaseConductivity * (lastPlasmaTemperature - lastCaseTemperature);
|
||||
plasmaTemperature -= plasmaCaseHeat / plasmaHeatCapacity;
|
||||
caseTemperature += plasmaCaseHeat / caseHeatCapacity;
|
||||
|
||||
//Transfer from casing to water if necessary
|
||||
if(activelyCooled)
|
||||
{
|
||||
double caseWaterHeat = caseWaterConductivity * caseTemperature;
|
||||
int waterToVaporize = (int)(caseWaterHeat / enthalpyOfVaporization);
|
||||
Mekanism.logger.info("Wanting to vaporise " + waterToVaporize + "mB of water");
|
||||
double caseWaterHeat = caseWaterConductivity * lastCaseTemperature;
|
||||
int waterToVaporize = (int)(steamTransferEfficiency * caseWaterHeat / enthalpyOfVaporization);
|
||||
//Mekanism.logger.info("Wanting to vaporise " + waterToVaporize + "mB of water");
|
||||
waterToVaporize = min(waterToVaporize, min(getWaterTank().getFluidAmount(), getSteamTank().getCapacity() - getSteamTank().getFluidAmount()));
|
||||
if(waterToVaporize > 0)
|
||||
{
|
||||
Mekanism.logger.info("Vaporising " + waterToVaporize + "mB of water");
|
||||
//Mekanism.logger.info("Vaporising " + waterToVaporize + "mB of water");
|
||||
getWaterTank().drain(waterToVaporize, true);
|
||||
getSteamTank().fill(new FluidStack(FluidRegistry.getFluid("steam"), waterToVaporize), true);
|
||||
}
|
||||
caseWaterHeat = waterToVaporize * enthalpyOfVaporization;
|
||||
caseWaterHeat = waterToVaporize * enthalpyOfVaporization / steamTransferEfficiency;
|
||||
caseTemperature -= caseWaterHeat / caseHeatCapacity;
|
||||
}
|
||||
|
||||
//Transfer from casing to environment
|
||||
double caseAirHeat = caseAirConductivity * caseTemperature;
|
||||
double caseAirHeat = caseAirConductivity * lastCaseTemperature;
|
||||
caseTemperature -= caseAirHeat / caseHeatCapacity;
|
||||
setBufferedEnergy(getBufferedEnergy() + caseAirHeat * thermocoupleEfficiency);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ public abstract class TileEntityReactorBlock extends TileEntityElectricBlock imp
|
|||
if(changed)
|
||||
{
|
||||
worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType());
|
||||
changed = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import mekanism.api.gas.GasTank;
|
|||
import mekanism.common.Mekanism;
|
||||
import mekanism.generators.common.FusionReactor;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
|
||||
|
@ -24,6 +25,7 @@ public class TileEntityReactorController extends TileEntityReactorBlock
|
|||
public TileEntityReactorController()
|
||||
{
|
||||
super("ReactorController", 1000000000);
|
||||
inventory = new ItemStack[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,6 +11,7 @@ import mekanism.api.gas.IGasHandler;
|
|||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.util.CableUtils;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
@ -23,7 +24,9 @@ public class TileEntityReactorPort extends TileEntityReactorBlock implements IFl
|
|||
public TileEntityReactorPort()
|
||||
{
|
||||
super("name", 1);
|
||||
inventory = new ItemStack[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFrame()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue