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