Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
telemenar authored Jan 31, 2021
1 parent fa9fb7c commit 2dd3119
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class GeneratorsConfig extends BaseMekanismConfig {
private static final String WIND_CATEGORY = "wind_generator";
private static final String HEAT_CATEGORY = "heat_generator";
private static final String HOHLRAUM_CATEGORY = "hohlraum";
private static final String FUSION_CATEGORY = "fusion_reactor";
private static final String FISSION_CATEGORY = "fission_reactor";

private final ForgeConfigSpec configSpec;
Expand Down Expand Up @@ -50,6 +51,10 @@ public class GeneratorsConfig extends BaseMekanismConfig {

public final CachedLongValue hohlraumMaxGas;
public final CachedLongValue hohlraumFillRate;

public final CachedDoubleValue fusionThermocoupleEfficiency;
public final CachedDoubleValue fusionCasingThermalConductivity;
public final CachedDoubleValue fusionWaterHeatingRatio;

GeneratorsConfig() {
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
Expand Down Expand Up @@ -101,6 +106,16 @@ public class GeneratorsConfig extends BaseMekanismConfig {
.defineList("windGenerationDimBlacklist", new ArrayList<>(), o -> o instanceof String && ResourceLocation.tryCreate(((String) o).toLowerCase(Locale.ROOT)) != null));
builder.pop();

builder.comment("Fusion Settings").push(FUSION_CATEGORY);
fusionThermocoupleEfficiency = CachedDoubleValue.wrap(this, builder.comment("The fraction of the heat dissipated from the case that is converted to Joules.")
.defineInRange("thermocoupleEfficiency", 0.05D, 0D, 1D));
fusionCasingThermalConductivity = CachedDoubleValue.wrap(this, builder.comment("The fraction fraction of heat from the casing that can be transfered to all sources that are not water. Will impact max heat, heat transfer to thermodynamic conductors, and power generation.")
.defineInRange("casingThermalConductivity", 0.1D, 0.001D, 1D));
fusionWaterHeatingRatio = CachedDoubleValue.wrap(this, builder.comment("The fraction of the heat from the casing that is dissipated to water when water cooling is in use. Will impact max heat, and steam generation.")
.defineInRange("waterHeatingRatio", 0.3D, 0D, 1D));
builder.pop();


builder.comment("Hohlraum Settings").push(HOHLRAUM_CATEGORY);
hohlraumMaxGas = CachedLongValue.wrap(this, builder.comment("Hohlraum capacity in mB.")
.defineInRange("maxGas", 10, 1, Long.MAX_VALUE));
Expand Down Expand Up @@ -141,4 +156,4 @@ public ForgeConfigSpec getConfigSpec() {
public Type getConfigType() {
return Type.SERVER;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ public class FusionReactorMultiblockData extends MultiblockData {
private static final double plasmaHeatCapacity = 100;
private static final double caseHeatCapacity = 1;
private static final double inverseInsulation = 100_000;
private static final double thermocoupleEfficiency = 0.05;
//Heat transfer metrics
private static final double plasmaCaseConductivity = 0.2;
private static final double caseWaterConductivity = 0.3;
private static final double caseAirConductivity = 0.1;

private final Set<ITileHeatHandler> heatHandlers = new ObjectOpenHashSet<>();

Expand Down Expand Up @@ -263,7 +260,7 @@ private void transferHeat() {
heatCapacitor.handleHeat(plasmaCaseHeat);

//Transfer from casing to water if necessary
double caseWaterHeat = caseWaterConductivity * (lastCaseTemperature - HeatAPI.AMBIENT_TEMP);
double caseWaterHeat = MekanismGeneratorsConfig.generators.fusionWaterHeatingRatio.get() * (lastCaseTemperature - HeatAPI.AMBIENT_TEMP);
int waterToVaporize = (int) (HeatUtils.getSteamEnergyEfficiency() * caseWaterHeat / HeatUtils.getWaterThermalEnthalpy());
waterToVaporize = Math.min(waterToVaporize, Math.min(waterTank.getFluidAmount(), MathUtils.clampToInt(steamTank.getNeeded())));
if (waterToVaporize > 0) {
Expand All @@ -278,9 +275,9 @@ private void transferHeat() {
}

//Passive energy generation
double caseAirHeat = caseAirConductivity * (lastCaseTemperature - HeatAPI.AMBIENT_TEMP);
double caseAirHeat = MekanismGeneratorsConfig.generators.fusionCasingThermalConductivity.get() * (lastCaseTemperature - HeatAPI.AMBIENT_TEMP);
heatCapacitor.handleHeat(-caseAirHeat);
energyContainer.insert(FloatingLong.create(caseAirHeat * thermocoupleEfficiency), Action.EXECUTE, AutomationType.INTERNAL);
energyContainer.insert(FloatingLong.create(caseAirHeat * MekanismGeneratorsConfig.generators.fusionThermocoupleEfficiency.get()), Action.EXECUTE, AutomationType.INTERNAL);
}

public void setLastPlasmaTemp(double temp) {
Expand Down Expand Up @@ -345,42 +342,45 @@ protected int getMultiblockRedstoneLevel() {
}

public int getMinInjectionRate(boolean active) {
double k = active ? caseWaterConductivity : 0;
double k = active ? MekanismGeneratorsConfig.generators.fusionWaterHeatingRatio.get() : 0;
double caseAirConductivity = MekanismGeneratorsConfig.generators.fusionCasingThermalConductivity.get();
double aMin = burnTemperature * burnRatio * plasmaCaseConductivity * (k + caseAirConductivity) /
(MekanismGeneratorsConfig.generators.energyPerFusionFuel.get().doubleValue() * burnRatio * (plasmaCaseConductivity + k + caseAirConductivity) -
plasmaCaseConductivity * (k + caseAirConductivity));
return (int) (2 * Math.ceil(aMin / 2D));
}

public double getMaxPlasmaTemperature(boolean active) {
double k = active ? caseWaterConductivity : 0;
double k = active ? MekanismGeneratorsConfig.generators.fusionWaterHeatingRatio.get() : 0;
double caseAirConductivity = MekanismGeneratorsConfig.generators.fusionCasingThermalConductivity.get();
return injectionRate * MekanismGeneratorsConfig.generators.energyPerFusionFuel.get().doubleValue() / plasmaCaseConductivity *
(plasmaCaseConductivity + k + caseAirConductivity) / (k + caseAirConductivity);
}

public double getMaxCasingTemperature(boolean active) {
double k = active ? caseWaterConductivity : 0;
return MekanismGeneratorsConfig.generators.energyPerFusionFuel.get().multiply(injectionRate).divide(k + caseAirConductivity).doubleValue();
double k = active ? MekanismGeneratorsConfig.generators.fusionWaterHeatingRatio.get() : 0;
return MekanismGeneratorsConfig.generators.energyPerFusionFuel.get().multiply(injectionRate).divide(k + MekanismGeneratorsConfig.generators.fusionCasingThermalConductivity.get()).doubleValue();
}

public double getIgnitionTemperature(boolean active) {
double k = active ? caseWaterConductivity : 0;
double k = active ? MekanismGeneratorsConfig.generators.fusionWaterHeatingRatio.get() : 0;
double caseAirConductivity = MekanismGeneratorsConfig.generators.fusionCasingThermalConductivity.get();
double energyPerFusionFuel = MekanismGeneratorsConfig.generators.energyPerFusionFuel.get().doubleValue();
return burnTemperature * energyPerFusionFuel * burnRatio * (plasmaCaseConductivity + k + caseAirConductivity) /
(energyPerFusionFuel * burnRatio * (plasmaCaseConductivity + k + caseAirConductivity) - plasmaCaseConductivity * (k + caseAirConductivity));
}

public FloatingLong getPassiveGeneration(boolean active, boolean current) {
double temperature = current ? getLastCaseTemp() : getMaxCasingTemperature(active);
return FloatingLong.create(thermocoupleEfficiency * caseAirConductivity * temperature);
return FloatingLong.create(MekanismGeneratorsConfig.generators.fusionThermocoupleEfficiency.get() * MekanismGeneratorsConfig.generators.fusionCasingThermalConductivity.get() * temperature);
}

public long getSteamPerTick(boolean current) {
double temperature = current ? getLastCaseTemp() : getMaxCasingTemperature(true);
return MathUtils.clampToLong(HeatUtils.getSteamEnergyEfficiency() * caseWaterConductivity * temperature / HeatUtils.getWaterThermalEnthalpy());
return MathUtils.clampToLong(HeatUtils.getSteamEnergyEfficiency() * MekanismGeneratorsConfig.generators.fusionWaterHeatingRatio.get() * temperature / HeatUtils.getWaterThermalEnthalpy());
}

public static double getInverseConductionCoefficient() {
return 1 / caseAirConductivity;
return 1 / MekanismGeneratorsConfig.generators.fusionCasingThermalConductivity.get();
}
}

0 comments on commit 2dd3119

Please sign in to comment.