Skip to content

Commit

Permalink
feat: resolve some TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu committed Jun 5, 2024
1 parent 765ca05 commit 73eb670
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 38 deletions.
44 changes: 8 additions & 36 deletions src/main/java/gregtech/api/nuclear/fission/FissionReactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,15 @@ public class FissionReactor {
private ArrayList<ControlRod> effectiveControlRods;
private ArrayList<CoolantChannel> effectiveCoolantChannels;

// TODO: Verify usefulness of the following things
private int numberOfComponents;

private double totNeutronSources;
private double avgGeometricFactorSlowNeutrons;
private double avgGeometricFactorFastNeutrons;

// TODO: Make this configurable
private int geometricIntegrationSteps = 100;

// Wtf is lSlow
private double lSlow;
private double lFast;
private double kSlow;
private double kFast;
private double k;

private double avgCoolantTemperature;
private double controlRodFactor;

// TODO: Determine tolerance range from config
public double kEff; // criticality value, based on k

// Is this still needed?
private double avgBoilingPoint;
private double avgAbsorption;
private double avgPressure;
private double avgModeration;

/**
* Thresholds important for determining the evolution of the reactor ^^^ This is a very epic comment
Expand Down Expand Up @@ -223,7 +204,6 @@ public void prepareThermalProperties() {
*/
if (reactorLayout[i][j] != null && reactorLayout[i][j].isValid()) {
reactorLayout[i][j].setPos(i, j);
numberOfComponents++;
maxTemperature = Double.min(maxTemperature, reactorLayout[i][j].getMaxTemperature());
structuralMass += reactorLayout[i][j].getMass();
if (reactorLayout[i][j] instanceof FuelRod) {
Expand All @@ -249,6 +229,7 @@ public void prepareThermalProperties() {
}

public void computeGeometry() {
moderatorTipped = false;
double[][] geometricMatrixSlowNeutrons = new double[fuelRods.size()][fuelRods.size()];
double[][] geometricMatrixFastNeutrons = new double[fuelRods.size()][fuelRods.size()];

Expand All @@ -268,12 +249,12 @@ public void computeGeometry() {
* Geometric factor calculation is done by (rough) numerical integration along a straight path between
* the two cells
*/
for (int t = 0; t < geometricIntegrationSteps; t++) {
for (int t = 0; t < ConfigHolder.machines.fissionReactorResolution; t++) {
double[] pos = { .5, .5 };
pos[0] += (fuelRods.get(j).getPos()[0] - fuelRods.get(i).getPos()[0]) *
((float) t / geometricIntegrationSteps) + fuelRods.get(i).getPos()[0];
((float) t / ConfigHolder.machines.fissionReactorResolution) + fuelRods.get(i).getPos()[0];
pos[1] += (fuelRods.get(j).getPos()[1] - fuelRods.get(i).getPos()[1]) *
((float) t / geometricIntegrationSteps) + fuelRods.get(i).getPos()[1];
((float) t / ConfigHolder.machines.fissionReactorResolution) + fuelRods.get(i).getPos()[1];
ReactorComponent component = reactorLayout[(int) Math.floor(pos[0])][(int) Math.floor(pos[1])];

if (component == null) {
Expand All @@ -298,6 +279,9 @@ public void computeGeometry() {
if (component instanceof ControlRod) {
if (!controlRodsHit.contains(component)) {
controlRodsHit.add((ControlRod) component);
if (((ControlRod) component).hasModeratorTip()) {
moderatorTipped = true;
}
}
} else if (component instanceof CoolantChannel) {
if (!coolantChannelsHit.contains(component)) {
Expand All @@ -314,7 +298,7 @@ public void computeGeometry() {
* The fraction of fast neutrons is simply one minus the fraction of slow neutrons
*/
if (pathIsClear) {
mij /= geometricIntegrationSteps;
mij /= ConfigHolder.machines.fissionReactorResolution;
geometricMatrixSlowNeutrons[i][j] = geometricMatrixSlowNeutrons[j][i] = (1. -
Math.exp(-mij * fuelRods.get(i).getDistance(fuelRods.get(j)))) /
fuelRods.get(i).getDistance(fuelRods.get(j));
Expand Down Expand Up @@ -352,8 +336,6 @@ public void computeGeometry() {

avgFuelRodDistance += i.getDistance(j);
}
totNeutronSources += i.getNeutronSourceIntensity();

avgHighEnergyFissionFactor += i.getHEFissionFactor();
avgLowEnergyFissionFactor += i.getLEFissionFactor();
avgHighEnergyCaptureFactor += i.getHECaptureFactor();
Expand All @@ -371,9 +353,6 @@ public void computeGeometry() {

avgFuelRodDistance /= 2. * fuelRods.size();

lSlow = avgFuelRodDistance / (2200. * avgLowEnergyCaptureFactor);
lFast = avgFuelRodDistance / (15000000. * avgHighEnergyCaptureFactor);

kSlow = avgLowEnergyFissionFactor / avgLowEnergyCaptureFactor * avgGeometricFactorSlowNeutrons;
kFast = avgHighEnergyFissionFactor / avgHighEnergyCaptureFactor * avgGeometricFactorFastNeutrons;

Expand All @@ -394,7 +373,6 @@ public void computeGeometry() {
ConfigHolder.machines.nuclearPowerMultiplier;

controlRodFactor = ControlRod.controlRodFactor(effectiveControlRods, this.controlRodInsertion);
avgCoolantTemperature /= coolantChannels.size();

this.prepareInitialConditions();

Expand Down Expand Up @@ -432,8 +410,6 @@ protected void computeCoolantChannelWeights() {
public void prepareInitialConditions() {
coolantBaseTemperature = 0;
coolantBoilingPointStandardPressure = 0;
avgAbsorption = 0;
avgModeration = 0;
avgPressure = 0;
coolantHeatOfVaporization = 0;
for (CoolantChannel channel : effectiveCoolantChannels) {
Expand All @@ -444,10 +420,6 @@ public void prepareInitialConditions() {
channel.getWeight();
coolantBoilingPointStandardPressure += prop.getBoilingPoint() *
channel.getWeight();
avgAbsorption += prop.getAbsorption() *
channel.getWeight();
avgModeration += prop.getModerationFactor() *
channel.getWeight();
avgPressure += prop.getPressure() *
channel.getWeight();
coolantHeatOfVaporization += prop.getHeatOfVaporization() *
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/gregtech/common/ConfigHolder.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,12 @@ public static class MachineOptions {

@Config.Comment({ "The amount of water (in liters) that can be boiled by a single liter of hot coolant.",
"Default: 1" })
@Config.RangeInt(min = 0)
@Config.RangeInt(min = 1)
public double coolantRecovery = 1;

@Config.Comment({ "The level of detail to which fission reactors are analyzed. May cause more lag at higher values." })
@Config.RangeInt(min = 5, max = 10000)
public double fissionReactorResolution = 100;
}

public static class WorldGenOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,6 @@ public void receiveInitialSyncData(PacketBuffer buf) {
}
}

// TODO: Abstract the stats into its own class
public void syncReactorStats() {
this.temperature = this.fissionReactor.temperature;
this.maxTemperature = this.fissionReactor.maxTemperature;
Expand Down

0 comments on commit 73eb670

Please sign in to comment.