Skip to content

Commit

Permalink
fix: temperature spikes
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu committed Jul 9, 2024
1 parent 44a0b02 commit 395c450
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public class FissionReactor {
public boolean isOn = false;

protected static double responseFunction(double target, double current, double criticalRate) {
if (current <= 0) {
if (current < 0) {
if (criticalRate < 1) {
return 0;
} else {
Expand Down Expand Up @@ -550,7 +550,7 @@ public void updateNeutronPoisoning() {

public double getDecayHeat() {
return this.neutronPoisonAmount * 0.05 + this.decayProductsAmount * 0.1 + 0.0001; // The extra constant is to
// kickstart the reactor.
// kickstart the reactor.
}

/*
Expand Down Expand Up @@ -578,16 +578,15 @@ public void updatePower() {

this.decayProductsAmount += Math.max(power, 0.) / 1000;
} else {
this.power = responseFunction(Math.min(this.realMaxPower(), this.power * kEff), this.power,
1);
this.power *= 0.5;
}
this.decayProductsAmount *= decayProductRate;
}

public double realMaxPower() {
if (this.moderatorTipped && (this.controlRodInsertion <= 9. / 16 && this.controlRodInsertion >= 7. / 16)) {
return this.maxPower * 1.1;
} else if (this.isDepleted() || !this.isOn) {
} else if (!this.isOn) {
return this.getDecayHeat();
} else {
return this.maxPower;
Expand Down

0 comments on commit 395c450

Please sign in to comment.