Skip to content

Commit

Permalink
fixed a divide by zero error when calculating Conductivity
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauge committed Dec 6, 2024
1 parent 399164b commit 967b228
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
6 changes: 2 additions & 4 deletions ThermalDynamics/Data/Scripts/Thermodynamics/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public static Vector3I Unflatten(this Vector3I vector, long flatVector)

public static int LargestFace(this Vector3I vector)
{
int s1 = 0;
int s2 = 0;
int s1 = 1;
int s2 = 1;
for (int i = 0; i < 3; i++)
{
if (vector[i] >= s1)
Expand All @@ -50,8 +50,6 @@ public static int LargestFace(this Vector3I vector)
}
}



return s1*s2;
}

Expand Down
2 changes: 1 addition & 1 deletion ThermalDynamics/Data/Scripts/Thermodynamics/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static Settings GetDefaults()
EnableEnvironment = true,
EnableSolarHeat = true,
EnableDamage = true,
Frequency = 4,
Frequency = 3,
SimulationSpeed = 1,
VacuumTemperature = 2.7f,
SolarEnergy = 500f,
Expand Down
16 changes: 1 addition & 15 deletions ThermalDynamics/Data/Scripts/Thermodynamics/ThermalCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,11 @@ public ThermalCell(ThermalGrid g, IMySlimBlock b, ThermalCellDefinition def)
ThermalMassInv = 1f / (Definition.SpecificHeat * Mass);
Boltzmann = -1 * Definition.Emissivity * Tools.BoltzmannConstant;


//if (Mass < 500)
//{
// Definition.Conductivity = 50;
//}
//else
//{

// float value = (Definition.SpecificHeat * Definition.SpecificHeat * Mass * Mass * Block.CubeGrid.GridSize) / (Area * ((Block.Max + 1) - Block.Min).LargestFace());


//}

float value = (Definition.SpecificHeat * Mass * Block.CubeGrid.GridSize) / (6 * Area * ((Block.Max + 1) - Block.Min).LargestFace());

k = value * Definition.Conductivity;
Definition.Conductivity = value;


//MyLog.Default.Info($"face: {(Block.Max + 1) - Block.Min} -- {((Block.Max + 1) - Block.Min).LargestFace()} -- {(6 * Area * ((Block.Max + 1) - Block.Min).LargestFace())} --- other: {(Definition.SpecificHeat * Mass * Block.CubeGrid.GridSize)}");
UpdateHeat();
}

Expand Down

0 comments on commit 967b228

Please sign in to comment.