Basic realistic heat and latent heat support.
This commit is contained in:
parent
7d8c6c7f86
commit
d6fe7fa2c8
@ -3483,14 +3483,9 @@ void Simulation::update_particles_i(int start, int inc)
|
||||
|
||||
if (elements[t].Diffusion)//the random diffusion that gasses have
|
||||
{
|
||||
#ifdef REALISTIC
|
||||
//The magic number controlls diffusion speed
|
||||
parts[i].vx += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
|
||||
parts[i].vy += 0.05*sqrtf(parts[i].temp)*elements[t].Diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
|
||||
#else
|
||||
parts[i].vx += elements[t].Diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
|
||||
parts[i].vy += elements[t].Diffusion*(rand()/(0.5f*RAND_MAX)-1.0f);
|
||||
#endif
|
||||
}
|
||||
|
||||
j = surround_space = nt = 0;//if nt is 1 after this, then there is a particle around the current particle, that is NOT the current particle's type, for water movement.
|
||||
@ -3525,18 +3520,11 @@ void Simulation::update_particles_i(int start, int inc)
|
||||
|
||||
//heat transfer code
|
||||
h_count = 0;
|
||||
#ifdef REALISTIC
|
||||
if (t&&(t!=PT_HSWC||parts[i].life==10)&&(elements[t].HeatConduct*gel_scale))
|
||||
{
|
||||
float c_Cm = 0.0f;
|
||||
#else
|
||||
if (t&&(t!=PT_HSWC||parts[i].life==10)&&(elements[t].HeatConduct*gel_scale)>(rand()%250))
|
||||
{
|
||||
float c_Cm = 0.0f;
|
||||
#endif
|
||||
if (aheat_enable && !(elements[t].Properties&PROP_NOAMBHEAT))
|
||||
{
|
||||
#ifdef REALISTIC
|
||||
c_heat = parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]+273.15f)/256;
|
||||
c_Cm = 96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + 100*(pv[y/CELL][x/CELL]+273.15f)/256;
|
||||
pt = c_heat/c_Cm;
|
||||
@ -3545,12 +3533,6 @@ void Simulation::update_particles_i(int start, int inc)
|
||||
//Pressure increase from heat (temporary)
|
||||
pv[y/CELL][x/CELL] += (pt-hv[y/CELL][x/CELL])*0.004;
|
||||
hv[y/CELL][x/CELL] = pt;
|
||||
#else
|
||||
c_heat = (hv[y/CELL][x/CELL]-parts[i].temp)*0.04;
|
||||
c_heat = restrict_flt(c_heat, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP);
|
||||
parts[i].temp += c_heat;
|
||||
hv[y/CELL][x/CELL] -= c_heat;
|
||||
#endif
|
||||
}
|
||||
c_heat = 0.0f;
|
||||
c_Cm = 0.0f;
|
||||
@ -3566,20 +3548,15 @@ void Simulation::update_particles_i(int start, int inc)
|
||||
&&(rt!=PT_FILT||(t!=PT_BRAY&&t!=PT_PHOT&&t!=PT_BIZR&&t!=PT_BIZRG)))
|
||||
{
|
||||
surround_hconduct[j] = r>>8;
|
||||
#ifdef REALISTIC
|
||||
if (rt==PT_GEL)
|
||||
gel_scale = parts[r>>8].tmp*2.55f;
|
||||
else gel_scale = 1.0f;
|
||||
|
||||
c_heat += parts[r>>8].temp*96.645/elements[rt].HeatConduct*gel_scale*fabs(elements[rt].Weight);
|
||||
c_Cm += 96.645/elements[rt].HeatConduct*gel_scale*fabs(elements[rt].Weight);
|
||||
#else
|
||||
c_heat += parts[r>>8].temp;
|
||||
#endif
|
||||
h_count++;
|
||||
}
|
||||
}
|
||||
#ifdef REALISTIC
|
||||
if (t==PT_GEL)
|
||||
gel_scale = parts[i].tmp*2.55f;
|
||||
else gel_scale = 1.0f;
|
||||
@ -3592,14 +3569,6 @@ void Simulation::update_particles_i(int start, int inc)
|
||||
c_heat += parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight);
|
||||
c_Cm += 96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight);
|
||||
parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
|
||||
#else
|
||||
pt = (c_heat+parts[i].temp)/(h_count+1);
|
||||
pt = parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
|
||||
for (j=0; j<8; j++)
|
||||
{
|
||||
parts[surround_hconduct[j]].temp = pt;
|
||||
}
|
||||
#endif
|
||||
|
||||
ctemph = ctempl = pt;
|
||||
// change boiling point with pressure
|
||||
@ -3617,13 +3586,12 @@ void Simulation::update_particles_i(int start, int inc)
|
||||
|
||||
if (ctemph>elements[t].HighTemperature&&elements[t].HighTemperatureTransition>-1) {
|
||||
// particle type change due to high temperature
|
||||
#ifdef REALISTIC
|
||||
float dbt = ctempl - pt;
|
||||
if (elements[t].HighTemperatureTransition!=PT_NUM)
|
||||
{
|
||||
if (platent[t] <= (c_heat - (elements[t].HighTemperature - dbt)*c_Cm))
|
||||
if (elements[t].Enthalpy <= (c_heat - (elements[t].HighTemperature - dbt)*c_Cm))
|
||||
{
|
||||
pt = (c_heat - platent[t])/c_Cm;
|
||||
pt = (c_heat - elements[t].Enthalpy)/c_Cm;
|
||||
t = elements[t].HighTemperatureTransition;
|
||||
}
|
||||
else
|
||||
@ -3632,19 +3600,14 @@ void Simulation::update_particles_i(int start, int inc)
|
||||
s = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (elements[t].HighTemperatureTransition!=PT_NUM)
|
||||
t = elements[t].HighTemperatureTransition;
|
||||
#endif
|
||||
else if (t==PT_ICEI || t==PT_SNOW) {
|
||||
if (parts[i].ctype<PT_NUM&&parts[i].ctype!=t) {
|
||||
if (elements[parts[i].ctype].LowTemperatureTransition==t&&pt<=elements[parts[i].ctype].LowTemperature) s = 0;
|
||||
else {
|
||||
#ifdef REALISTIC
|
||||
//One ice table value for all it's kinds
|
||||
if (platent[t] <= (c_heat - (elements[parts[i].ctype].LowTemperature - dbt)*c_Cm))
|
||||
if (elements[t].Enthalpy <= (c_heat - (elements[parts[i].ctype].LowTemperature - dbt)*c_Cm))
|
||||
{
|
||||
pt = (c_heat - platent[t])/c_Cm;
|
||||
pt = (c_heat - elements[t].Enthalpy)/c_Cm;
|
||||
t = parts[i].ctype;
|
||||
parts[i].ctype = PT_NONE;
|
||||
parts[i].life = 0;
|
||||
@ -3654,20 +3617,14 @@ void Simulation::update_particles_i(int start, int inc)
|
||||
parts[i].temp = restrict_flt(elements[parts[i].ctype].LowTemperature - dbt, MIN_TEMP, MAX_TEMP);
|
||||
s = 0;
|
||||
}
|
||||
#else
|
||||
t = parts[i].ctype;
|
||||
parts[i].ctype = PT_NONE;
|
||||
parts[i].life = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else s = 0;
|
||||
}
|
||||
else if (t==PT_SLTW) {
|
||||
#ifdef REALISTIC
|
||||
if (platent[t] <= (c_heat - (elements[t].HighTemperature - dbt)*c_Cm))
|
||||
if (elements[t].Enthalpy <= (c_heat - (elements[t].HighTemperature - dbt)*c_Cm))
|
||||
{
|
||||
pt = (c_heat - platent[t])/c_Cm;
|
||||
pt = (c_heat - elements[t].Enthalpy)/c_Cm;
|
||||
|
||||
if (1>rand()%6) t = PT_SALT;
|
||||
else t = PT_WTRV;
|
||||
@ -3677,21 +3634,16 @@ void Simulation::update_particles_i(int start, int inc)
|
||||
parts[i].temp = restrict_flt(elements[t].HighTemperature - dbt, MIN_TEMP, MAX_TEMP);
|
||||
s = 0;
|
||||
}
|
||||
#else
|
||||
if (1>rand()%6) t = PT_SALT;
|
||||
else t = PT_WTRV;
|
||||
#endif
|
||||
}
|
||||
else s = 0;
|
||||
} else if (ctempl<elements[t].LowTemperature&&elements[t].LowTemperatureTransition>-1) {
|
||||
// particle type change due to low temperature
|
||||
#ifdef REALISTIC
|
||||
float dbt = ctempl - pt;
|
||||
if (elements[t].LowTemperatureTransition!=PT_NUM)
|
||||
{
|
||||
if (platent[elements[t].LowTemperatureTransition] >= (c_heat - (elements[t].LowTemperature - dbt)*c_Cm))
|
||||
if (elements[elements[t].LowTemperatureTransition].Enthalpy >= (c_heat - (elements[t].LowTemperature - dbt)*c_Cm))
|
||||
{
|
||||
pt = (c_heat + platent[elements[t].LowTemperatureTransition])/c_Cm;
|
||||
pt = (c_heat + elements[elements[t].LowTemperatureTransition].Enthalpy)/c_Cm;
|
||||
t = elements[t].LowTemperatureTransition;
|
||||
}
|
||||
else
|
||||
@ -3700,10 +3652,6 @@ void Simulation::update_particles_i(int start, int inc)
|
||||
s = 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (elements[t].LowTemperatureTransition!=PT_NUM)
|
||||
t = elements[t].LowTemperatureTransition;
|
||||
#endif
|
||||
else if (t==PT_WTRV) {
|
||||
if (pt<273.0f) t = PT_RIME;
|
||||
else t = PT_DSTW;
|
||||
@ -3735,13 +3683,11 @@ void Simulation::update_particles_i(int start, int inc)
|
||||
else s = 0;
|
||||
}
|
||||
else s = 0;
|
||||
#ifdef REALISTIC
|
||||
pt = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
|
||||
for (j=0; j<8; j++)
|
||||
{
|
||||
parts[surround_hconduct[j]].temp = pt;
|
||||
}
|
||||
#endif
|
||||
if (s) { // particle type change occurred
|
||||
if (t==PT_ICEI||t==PT_LAVA||t==PT_SNOW)
|
||||
parts[i].ctype = parts[i].type;
|
||||
@ -4528,7 +4474,6 @@ void Simulation::update_particles()//doesn't update the particles themselves, bu
|
||||
|
||||
Simulation::~Simulation()
|
||||
{
|
||||
delete[] platent;
|
||||
delete grav;
|
||||
delete air;
|
||||
for(int i = 0; i < tools.size(); i++)
|
||||
@ -4581,12 +4526,6 @@ Simulation::Simulation():
|
||||
memcpy(wtypes, wtypesT, wallCount * sizeof(wall_type));
|
||||
free(wtypesT);
|
||||
|
||||
platent = new unsigned[PT_NUM];
|
||||
int latentCount;
|
||||
unsigned int * platentT = LoadLatent(latentCount);
|
||||
memcpy(platent, platentT, latentCount * sizeof(unsigned int));
|
||||
free(platentT);
|
||||
|
||||
//elements = new Element[PT_NUM];
|
||||
std::vector<Element> elementList = GetElements();
|
||||
for(int i = 0; i < PT_NUM; i++)
|
||||
|
@ -50,7 +50,6 @@ public:
|
||||
Element elements[PT_NUM];
|
||||
//Element * elements;
|
||||
std::vector<SimTool*> tools;
|
||||
unsigned int * platent;
|
||||
wall_type wtypes[UI_WALLCOUNT];
|
||||
gol_menu gmenu[NGOL];
|
||||
int goltype[NGOL];
|
||||
|
@ -170,175 +170,3 @@ menu_section * LoadMenus(int & menuCount)
|
||||
memcpy(msectionsT, msections, SC_TOTAL*sizeof(menu_section));
|
||||
return msectionsT;
|
||||
}
|
||||
|
||||
unsigned int * LoadLatent(int & elementCount)
|
||||
{
|
||||
unsigned int platent[PT_NUM] =
|
||||
{
|
||||
/* NONE */ 0,
|
||||
/* DUST */ 0,
|
||||
/* WATR */ 7500,
|
||||
/* OIL */ 0,
|
||||
/* FIRE */ 0,
|
||||
/* STNE */ 0,
|
||||
/* LAVA */ 0,
|
||||
/* GUN */ 0,
|
||||
/* NITR */ 0,
|
||||
/* CLNE */ 0,
|
||||
/* GAS */ 0,
|
||||
/* C-4 */ 0,
|
||||
/* GOO */ 0,
|
||||
/* ICE */ 1095,
|
||||
/* METL */ 919,
|
||||
/* SPRK */ 0,
|
||||
/* SNOW */ 1095,
|
||||
/* WOOD */ 0,
|
||||
/* NEUT */ 0,
|
||||
/* PLUT */ 0,
|
||||
/* PLNT */ 0,
|
||||
/* ACID */ 0,
|
||||
/* VOID */ 0,
|
||||
/* WTRV */ 0,
|
||||
/* CNCT */ 0,
|
||||
/* DSTW */ 7500,
|
||||
/* SALT */ 0,
|
||||
/* SLTW */ 7500,
|
||||
/* DMND */ 0,
|
||||
/* BMTL */ 0,
|
||||
/* BRMT */ 0,
|
||||
/* PHOT */ 0,
|
||||
/* URAN */ 0,
|
||||
/* WAX */ 0,
|
||||
/* MWAX */ 0,
|
||||
/* PSCN */ 0,
|
||||
/* NSCN */ 0,
|
||||
/* LN2 */ 0,
|
||||
/* INSL */ 0,
|
||||
/* VACU */ 0,
|
||||
/* VENT */ 0,
|
||||
/* RBDM */ 0,
|
||||
/* LRBD */ 0,
|
||||
/* NTCT */ 0,
|
||||
/* SAND */ 0,
|
||||
/* GLAS */ 0,
|
||||
/* PTCT */ 0,
|
||||
/* BGLA */ 0,
|
||||
/* THDR */ 0,
|
||||
/* PLSM */ 0,
|
||||
/* ETRD */ 0,
|
||||
/* NICE */ 0,
|
||||
/* NBLE */ 0,
|
||||
/* BTRY */ 0,
|
||||
/* LCRY */ 0,
|
||||
/* STKM */ 0,
|
||||
/* SWCH */ 0,
|
||||
/* SMKE */ 0,
|
||||
/* DESL */ 0,
|
||||
/* COAL */ 0,
|
||||
/* LO2 */ 0,
|
||||
/* O2 */ 0,
|
||||
/* INWR */ 0,
|
||||
/* YEST */ 0,
|
||||
/* DYST */ 0,
|
||||
/* THRM */ 0,
|
||||
/* GLOW */ 0,
|
||||
/* BRCK */ 0,
|
||||
/* CFLM */ 0,
|
||||
/* FIRW */ 0,
|
||||
/* FUSE */ 0,
|
||||
/* FSEP */ 0,
|
||||
/* AMTR */ 0,
|
||||
/* BCOL */ 0,
|
||||
/* PCLN */ 0,
|
||||
/* HSWC */ 0,
|
||||
/* IRON */ 0,
|
||||
/* MORT */ 0,
|
||||
/* LIFE */ 0,
|
||||
/* DLAY */ 0,
|
||||
/* CO2 */ 0,
|
||||
/* DRIC */ 0,
|
||||
/* CBNW */ 7500,
|
||||
/* STOR */ 0,
|
||||
/* STOR */ 0,
|
||||
/* FREE */ 0,
|
||||
/* FREE */ 0,
|
||||
/* FREE */ 0,
|
||||
/* FREE */ 0,
|
||||
/* FREE */ 0,
|
||||
/* SPNG */ 0,
|
||||
/* RIME */ 0,
|
||||
/* FOG */ 0,
|
||||
/* BCLN */ 0,
|
||||
/* LOVE */ 0,
|
||||
/* DEUT */ 0,
|
||||
/* WARP */ 0,
|
||||
/* PUMP */ 0,
|
||||
/* FWRK */ 0,
|
||||
/* PIPE */ 0,
|
||||
/* FRZZ */ 0,
|
||||
/* FRZW */ 0,
|
||||
/* GRAV */ 0,
|
||||
/* BIZR */ 0,
|
||||
/* BIZRG*/ 0,
|
||||
/* BIZRS*/ 0,
|
||||
/* INST */ 0,
|
||||
/* ISOZ */ 0,
|
||||
/* ISZS */ 0,
|
||||
/* PRTI */ 0,
|
||||
/* PRTO */ 0,
|
||||
/* PSTE */ 0,
|
||||
/* PSTS */ 0,
|
||||
/* ANAR */ 0,
|
||||
/* VINE */ 0,
|
||||
/* INVS */ 0,
|
||||
/* EQVE */ 0,
|
||||
/* SPWN2*/ 0,
|
||||
/* SPAWN*/ 0,
|
||||
/* SHLD1*/ 0,
|
||||
/* SHLD2*/ 0,
|
||||
/* SHLD3*/ 0,
|
||||
/* SHLD4*/ 0,
|
||||
/* LOlZ */ 0,
|
||||
/* WIFI */ 0,
|
||||
/* FILT */ 0,
|
||||
/* ARAY */ 0,
|
||||
/* BRAY */ 0,
|
||||
/* STKM2*/ 0,
|
||||
/* BOMB */ 0,
|
||||
/* C-5 */ 0,
|
||||
/* SING */ 0,
|
||||
/* QRTZ */ 0,
|
||||
/* PQRT */ 0,
|
||||
/* EMP */ 0,
|
||||
/* BREL */ 0,
|
||||
/* ELEC */ 0,
|
||||
/* ACEL */ 0,
|
||||
/* DCEL */ 0,
|
||||
/* TNT */ 0,
|
||||
/* IGNP */ 0,
|
||||
/* BOYL */ 0,
|
||||
/* GEL */ 0,
|
||||
/* FREE */ 0,
|
||||
/* FREE */ 0,
|
||||
/* FREE */ 0,
|
||||
/* FREE */ 0,
|
||||
/* WIND */ 0,
|
||||
/* H2 */ 0,
|
||||
/* SOAP */ 0,
|
||||
/* NBHL */ 0,
|
||||
/* NWHL */ 0,
|
||||
/* MERC */ 0,
|
||||
/* PBCN */ 0,
|
||||
/* GPMP */ 0,
|
||||
/* CLST */ 0,
|
||||
/* WIRE */ 0,
|
||||
/* GBMB */ 0,
|
||||
/* FIGH */ 0,
|
||||
/* FRAY */ 0,
|
||||
/* REPL */ 0,
|
||||
};
|
||||
elementCount = PT_NUM;
|
||||
unsigned int * platentT = (unsigned int*)malloc(PT_NUM*sizeof(unsigned int));
|
||||
memcpy(platentT, platent, PT_NUM*sizeof(unsigned int));
|
||||
return platentT;
|
||||
}
|
||||
|
@ -172,6 +172,4 @@ wall_type * LoadWalls(int & wallCount);
|
||||
|
||||
menu_section * LoadMenus(int & menuCount);
|
||||
|
||||
unsigned int * LoadLatent(int & elementCount);
|
||||
|
||||
#endif /* SIMULATIONDATA_H_ */
|
||||
|
@ -26,6 +26,7 @@ Element::Element():
|
||||
Weight(50),
|
||||
|
||||
Temperature(273.15f),
|
||||
Enthalpy(0.0f),
|
||||
HeatConduct(128),
|
||||
Description("No description"),
|
||||
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
int Weight;
|
||||
int MenuSection;
|
||||
float Temperature;
|
||||
float Enthalpy;
|
||||
unsigned char HeatConduct;
|
||||
char *Description;
|
||||
char State;
|
||||
|
@ -27,7 +27,7 @@ Element_FIRE::Element_FIRE()
|
||||
Weight = 2;
|
||||
|
||||
Temperature = R_TEMP+400.0f+273.15f;
|
||||
HeatConduct = 88;
|
||||
HeatConduct = 1;
|
||||
Description = "Ignites flammable materials. Heats air.";
|
||||
|
||||
State = ST_GAS;
|
||||
|
@ -27,6 +27,7 @@ Element_WATR::Element_WATR()
|
||||
Weight = 30;
|
||||
|
||||
Temperature = R_TEMP-2.0f +273.15f;
|
||||
Enthalpy = 7500;
|
||||
HeatConduct = 29;
|
||||
Description = "Liquid. Conducts electricity. Freezes. Extinguishes fires.";
|
||||
|
||||
|
Reference in New Issue
Block a user