Skip to content

Commit

Permalink
feat: mean generation time time
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu committed Jul 8, 2024
1 parent 4e126df commit 44a0b02
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 35 deletions.
30 changes: 17 additions & 13 deletions src/main/java/gregtech/api/nuclear/fission/FissionReactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public class FissionReactor {
public double decayProductsAmount;
public double envTemperature = roomTemperature; // maybe gotten from config per dim
public double accumulatedHydrogen;
public double weightedGenerationTime = 2; // The mean generation time in seconds, accounting for delayed neutrons

public double maxTemperature = 2000;
// Pascals
Expand All @@ -111,8 +112,7 @@ public class FissionReactor {
// Minecraft days, and yes, I am using this for plutonium too
public static double poisonFraction = 0.063; // Xenon-135 yield from fission
public static double crossSectionRatio = 4; // The ratio between the cross section for typical fuels and xenon-135;
public static double weightedGenerationTimeDelayed = 2; // The mean generation time in seconds, adjusted for
// simple Minecraft players


// very much changed here for balance purposes

Expand Down Expand Up @@ -406,12 +406,16 @@ public void prepareInitialConditions() {
coolantBoilingPointStandardPressure = 0;
coolantHeatOfVaporization = 0;
maxFuelDepletion = 0;
weightedGenerationTime = 0;

for (FuelRod rod : fuelRods) {
maxFuelDepletion += rod.getFuel().getDuration();
maxFuelDepletion += rod.getDuration();
weightedGenerationTime += rod.getNeutronGenerationTime();
}
if (fuelDepletion < 0) {
fuelDepletion = maxFuelDepletion;
}
weightedGenerationTime /= fuelRods.size();

for (CoolantChannel channel : effectiveCoolantChannels) {

Expand Down Expand Up @@ -565,7 +569,7 @@ public void updatePower() {
neutronPoisonAmount * crossSectionRatio / surfaceArea + controlRodFactor);
this.kEff = Math.max(0, this.kEff);

double inverseReactorPeriod = (this.kEff - 1) / weightedGenerationTimeDelayed;
double inverseReactorPeriod = (this.kEff - 1) / weightedGenerationTime;

this.power += 0.001; // Let it kickstart itself
this.power *= Math.exp(inverseReactorPeriod);
Expand Down Expand Up @@ -647,8 +651,14 @@ public void regulateControlRods() {
this.controlRodInsertion = Math.min(1, this.controlRodInsertion);
this.controlRodFactor = ControlRod.controlRodFactor(effectiveControlRods, this.controlRodInsertion);
}
if (load > 3. / 10) {
if (kEff > 1.005) {
if (load > 9. / 10) {
if (kEff > 1) {
this.controlRodInsertion += 1f / 255;
this.controlRodInsertion = Math.min(1, this.controlRodInsertion);
this.controlRodFactor = ControlRod.controlRodFactor(effectiveControlRods, this.controlRodInsertion);
}
} else if (load > 3. / 10) {
if (kEff > 1.008) {
this.controlRodInsertion += 2f / 255;
this.controlRodInsertion = Math.min(1, this.controlRodInsertion);
this.controlRodFactor = ControlRod.controlRodFactor(effectiveControlRods, this.controlRodInsertion);
Expand All @@ -658,13 +668,7 @@ public void regulateControlRods() {
this.controlRodFactor = ControlRod.controlRodFactor(effectiveControlRods, this.controlRodInsertion);
}
}
if (load > 9. / 10) {
if (kEff > 1) {
this.controlRodInsertion += 1f / 255;
this.controlRodInsertion = Math.min(1, this.controlRodInsertion);
this.controlRodFactor = ControlRod.controlRodFactor(effectiveControlRods, this.controlRodInsertion);
}
}

}

public void turnOff() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
public class FuelRod extends ReactorComponent {

private FissionFuelProperty fuel;
private final double neutronSourceIntensity;

public FuelRod(double maxTemperature, double thermalConductivity, FissionFuelProperty fuel, double mass,
double neutronSourceIntensity) {
public FuelRod(double maxTemperature, double thermalConductivity, FissionFuelProperty fuel, double mass) {
super(0, maxTemperature, thermalConductivity, mass, true);
this.fuel = fuel;
this.neutronSourceIntensity = neutronSourceIntensity;
}

public double getDuration() {
return fuel.getDuration();
}

public double getHEFissionFactor() {
Expand All @@ -30,8 +31,8 @@ public double getLECaptureFactor() {
return fuel.getSlowNeutronCaptureCrossSection();
}

public double getNeutronSourceIntensity() {
return neutronSourceIntensity;
public double getNeutronGenerationTime() {
return fuel.getNeutronGenerationTime();
}

public FissionFuelProperty getFuel() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/unification/material/Material.java
Original file line number Diff line number Diff line change
Expand Up @@ -1089,12 +1089,12 @@ public Builder itemPipeProperties(int priority, float stacksPerSec) {
public Builder fissionFuelProperties(int maxTemperature, int duration, double slowNeutronCaptureCrossSection,
double fastNeutronCaptureCrossSection,
double slowNeutronFissionCrossSection,
double fastNeutronFissionCrossSection) {
double fastNeutronFissionCrossSection, double neutronGenerationTime) {
properties.ensureSet(PropertyKey.DUST);
properties.setProperty(PropertyKey.FISSION_FUEL,
new FissionFuelProperty(maxTemperature, duration, slowNeutronCaptureCrossSection,
fastNeutronCaptureCrossSection, slowNeutronFissionCrossSection,
fastNeutronFissionCrossSection));
fastNeutronFissionCrossSection, neutronGenerationTime));
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public static void register() {
.color(0x232323).iconSet(METALLIC)
.flags(DISABLE_DECOMPOSITION)
.components(HighEnrichedUraniumDioxide, 1, DepletedUraniumDioxide, 19)
.fissionFuelProperties(1500, 750, 55., 1., 2500., 0.)
.fissionFuelProperties(1500, 750, 55., 1., 2500., 0., 3.5)
.build()
.setFormula("UO2", true);

Expand All @@ -518,7 +518,7 @@ public static void register() {
.color(0x242826).iconSet(METALLIC)
.flags(DISABLE_DECOMPOSITION)
.components(HighEnrichedUraniumDioxide, 1, DepletedUraniumDioxide, 4)
.fissionFuelProperties(1800, 600, 40., 1., 3000., 0.)
.fissionFuelProperties(1800, 600, 40., 1., 3000., 0., 2.5)
.build()
.setFormula("UO2", true);

Expand All @@ -527,7 +527,7 @@ public static void register() {
.color(0x62C032).iconSet(METALLIC)
.flags(DISABLE_DECOMPOSITION)
.components(FissilePlutoniumDioxide, 1, Uraninite, 19)
.fissionFuelProperties(1600, 1000, 50., 10., 4000., 10.)
.fissionFuelProperties(1600, 1000, 50., 10., 4000., 10., 1.5)
.build()
.setFormula("(U,Pu)O2", true);

Expand All @@ -536,7 +536,7 @@ public static void register() {
.color(0x7EA432).iconSet(METALLIC)
.flags(DISABLE_DECOMPOSITION)
.components(FissilePlutoniumDioxide, 1, Uraninite, 4)
.fissionFuelProperties(2000, 800, 35., 25., 5500., 25.)
.fissionFuelProperties(2000, 800, 35., 25., 5500., 0., 1)
.build()
.setFormula("(U,Pu)O2", true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class FissionFuelProperty implements IMaterialProperty {
private double slowNeutronFissionCrossSection;
// How likely it is for a not-yet-moderated neutron to cause fission in this fuel.
private double fastNeutronFissionCrossSection;
// The average time for a neutron to be emitted during a fission event. Do not make this accurate.
private double neutronGenerationTime;

@Override
public void verifyProperty(MaterialProperties properties) {
Expand All @@ -22,17 +24,14 @@ public void verifyProperty(MaterialProperties properties) {

public FissionFuelProperty(int maxTemperature, int duration, double slowNeutronCaptureCrossSection,
double fastNeutronCaptureCrossSection, double slowNeutronFissionCrossSection,
double fastNeutronFissionCrossSection) {
double fastNeutronFissionCrossSection, double neutronGenerationTime) {
this.maxTemperature = maxTemperature;
this.duration = duration;
this.slowNeutronCaptureCrossSection = slowNeutronCaptureCrossSection;
this.fastNeutronCaptureCrossSection = fastNeutronCaptureCrossSection;
this.slowNeutronFissionCrossSection = slowNeutronFissionCrossSection;
this.fastNeutronFissionCrossSection = fastNeutronFissionCrossSection;
}

public FissionFuelProperty() {
this(1, 1, 0.1D, 0.1D, 0.1D, 0.1D);
this.neutronGenerationTime = neutronGenerationTime;
}

public int getMaxTemperature() {
Expand Down Expand Up @@ -84,4 +83,12 @@ public double getFastNeutronFissionCrossSection() {
public void setFastNeutronFissionCrossSection(double fastNeutronFissionCrossSection) {
this.fastNeutronFissionCrossSection = fastNeutronFissionCrossSection;
}

public double getNeutronGenerationTime() {
return neutronGenerationTime;
}

public void setNeutronGenerationTime(double neutronGenerationTime) {
this.neutronGenerationTime = neutronGenerationTime;
}
}
4 changes: 3 additions & 1 deletion src/main/java/gregtech/api/unification/ore/OrePrefix.java
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ public class OrePrefix {
mat.getProperty(PropertyKey.FISSION_FUEL).getMaxTemperature()),
I18n.format("metaitem.nuclear.tooltip.cross_sections",
mat.getProperty(PropertyKey.FISSION_FUEL).getFastNeutronFissionCrossSection(),
mat.getProperty(PropertyKey.FISSION_FUEL).getSlowNeutronFissionCrossSection())));
mat.getProperty(PropertyKey.FISSION_FUEL).getSlowNeutronFissionCrossSection()),
I18n.format("metaitem.nuclear.tooltip.neutron_time",
mat.getProperty(PropertyKey.FISSION_FUEL).getNeutronGenerationTime())));
public static final OrePrefix fuelRodDepleted = new OrePrefix("fuelRodDepleted", -1, null,
MaterialIconType.fuelRodDepleted, 0, material -> material.hasProperty(PropertyKey.FISSION_FUEL),
mat -> Collections.singletonList(I18n.format("metaitem.nuclear.tooltip.radioactive")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -851,14 +851,13 @@ private void lockAndPrepareReactor() {
foundFuel = true;
if (fissionReactor.fuelDepletion == 0 || fuelIn.getPartialFuel() == null) {
fuelIn.setPartialFuel(mat.material);
component = new FuelRod(property.getMaxTemperature(), 1, property, 650, 3);
component = new FuelRod(property.getMaxTemperature(), 1, property, 650);
fuelIn.setInternalFuelRod(component);
} else {
// It's guaranteed to have this property (if the implementation is correct).
FissionFuelProperty partialProp = fuelIn.getPartialFuel()
.getProperty(PropertyKey.FISSION_FUEL);
component = new FuelRod(partialProp.getMaxTemperature(), 1, partialProp, 650,
3);
component = new FuelRod(partialProp.getMaxTemperature(), 1, partialProp, 650);
fuelIn.setInternalFuelRod(component);
}
fuelIn.setInternalFuelRod(component);
Expand Down
Loading

0 comments on commit 44a0b02

Please sign in to comment.