REALISTIC - Latent heat. It may be buggy, and enthalpy table isn't

filled, but it works.
This commit is contained in:
savask 2012-04-01 00:23:56 +07:00
parent 57aa7b88f1
commit 4b4830b5a4
3 changed files with 246 additions and 4 deletions

View File

@ -491,6 +491,7 @@ typedef struct part_transition part_transition;
// TODO: falldown, properties, state - should at least one of these be removed? // TODO: falldown, properties, state - should at least one of these be removed?
extern part_type ptypes[PT_NUM]; extern part_type ptypes[PT_NUM];
extern unsigned int platent[PT_NUM];
// temporarily define abbreviations for impossible p/t values // temporarily define abbreviations for impossible p/t values
#define IPL -257.0f #define IPL -257.0f

View File

@ -352,6 +352,173 @@ part_transition ptransitions[PT_NUM] =
/* FRAY */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* FRAY */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
/* REPL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT}, /* REPL */ {IPL, NT, IPH, NT, ITL, NT, ITH, NT},
}; };
// This is an enthalpy values table, converted into TPT imaginary units
// table value is - 750/226*enthalpy value of the material
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,
/* FREE */ 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,
};
#undef IPL #undef IPL
#undef IPH #undef IPH
#undef ITL #undef ITL

View File

@ -1904,15 +1904,18 @@ void update_particles_i(pixel *vid, int start, int inc)
pt = (c_heat+parts[i].temp*96.645)/(c_Cm+96.645); pt = (c_heat+parts[i].temp*96.645)/(c_Cm+96.645);
else else
pt = (c_heat+parts[i].temp*96.645/ptypes[t].hconduct*fabs(ptypes[t].weight))/(c_Cm+96.645/ptypes[t].hconduct*fabs(ptypes[t].weight)); pt = (c_heat+parts[i].temp*96.645/ptypes[t].hconduct*fabs(ptypes[t].weight))/(c_Cm+96.645/ptypes[t].hconduct*fabs(ptypes[t].weight));
c_heat += parts[i].temp*96.645/ptypes[t].hconduct*fabs(ptypes[t].weight);
c_Cm += 96.645/ptypes[t].hconduct*fabs(ptypes[t].weight);
parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
#else #else
pt = (c_heat+parts[i].temp)/(h_count+1); pt = (c_heat+parts[i].temp)/(h_count+1);
#endif
pt = parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP); pt = parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP);
for (j=0; j<8; j++) for (j=0; j<8; j++)
{ {
parts[surround_hconduct[j]].temp = pt; parts[surround_hconduct[j]].temp = pt;
} }
#endif
ctemph = ctempl = pt; ctemph = ctempl = pt;
// change boiling point with pressure // change boiling point with pressure
@ -1925,29 +1928,93 @@ void update_particles_i(pixel *vid, int start, int inc)
s = 1; s = 1;
if (ctemph>ptransitions[t].thv&&ptransitions[t].tht>-1) { if (ctemph>ptransitions[t].thv&&ptransitions[t].tht>-1) {
// particle type change due to high temperature // particle type change due to high temperature
#ifdef REALISTIC
float dbt = ctempl - pt;
if (ptransitions[t].tht!=PT_NUM)
{
if (platent[t] <= (c_heat - (ptransitions[t].thv - dbt)*c_Cm))
{
pt = (c_heat - platent[t])/c_Cm;
t = ptransitions[t].tht;
}
else
{
parts[i].temp = restrict_flt(ptransitions[t].thv - dbt, MIN_TEMP, MAX_TEMP);
s = 0;
}
}
#else
if (ptransitions[t].tht!=PT_NUM) if (ptransitions[t].tht!=PT_NUM)
t = ptransitions[t].tht; t = ptransitions[t].tht;
#endif
else if (t==PT_ICEI) { else if (t==PT_ICEI) {
if (parts[i].ctype>0&&parts[i].ctype<PT_NUM&&parts[i].ctype!=PT_ICEI) { if (parts[i].ctype<PT_NUM&&parts[i].ctype!=PT_ICEI) {
if (ptransitions[parts[i].ctype].tlt==PT_ICEI&&pt<=ptransitions[parts[i].ctype].tlv) s = 0; if (ptransitions[parts[i].ctype].tlt==PT_ICEI&&pt<=ptransitions[parts[i].ctype].tlv) s = 0;
else { else {
#ifdef REALISTIC
//One ice table value for all it's kinds
if (platent[t] <= (c_heat - (ptransitions[parts[i].ctype].tlv - dbt)*c_Cm))
{
pt = (c_heat - platent[t])/c_Cm;
t = parts[i].ctype;
parts[i].ctype = PT_NONE;
parts[i].life = 0;
}
else
{
parts[i].temp = restrict_flt(ptransitions[parts[i].ctype].tlv - dbt, MIN_TEMP, MAX_TEMP);
s = 0;
}
#else
t = parts[i].ctype; t = parts[i].ctype;
parts[i].ctype = PT_NONE; parts[i].ctype = PT_NONE;
parts[i].life = 0; parts[i].life = 0;
#endif
} }
} }
else if (pt>274.0f) t = PT_WATR;
else s = 0; else s = 0;
} }
else if (t==PT_SLTW) { else if (t==PT_SLTW) {
#ifdef REALISTIC
if (platent[t] <= (c_heat - (ptransitions[t].thv - dbt)*c_Cm))
{
pt = (c_heat - platent[t])/c_Cm;
if (1>rand()%6) t = PT_SALT;
else t = PT_WTRV;
}
else
{
parts[i].temp = restrict_flt(ptransitions[t].thv - dbt, MIN_TEMP, MAX_TEMP);
s = 0;
}
#else
if (1>rand()%6) t = PT_SALT; if (1>rand()%6) t = PT_SALT;
else t = PT_WTRV; else t = PT_WTRV;
#endif
} }
else s = 0; else s = 0;
} else if (ctempl<ptransitions[t].tlv&&ptransitions[t].tlt>-1) { } else if (ctempl<ptransitions[t].tlv&&ptransitions[t].tlt>-1) {
// particle type change due to low temperature // particle type change due to low temperature
#ifdef REALISTIC
float dbt = ctempl - pt;
if (ptransitions[t].tlt!=PT_NUM)
{
if (platent[ptransitions[t].tlt] >= (c_heat - (ptransitions[t].tlv - dbt)*c_Cm))
{
pt = (c_heat + platent[ptransitions[t].tlt])/c_Cm;
t = ptransitions[t].tlt;
}
else
{
parts[i].temp = restrict_flt(ptransitions[t].tlv - dbt, MIN_TEMP, MAX_TEMP);
s = 0;
}
}
#else
if (ptransitions[t].tlt!=PT_NUM) if (ptransitions[t].tlt!=PT_NUM)
t = ptransitions[t].tlt; t = ptransitions[t].tlt;
#endif
else if (t==PT_WTRV) { else if (t==PT_WTRV) {
if (pt<273.0f) t = PT_RIME; if (pt<273.0f) t = PT_RIME;
else t = PT_DSTW; else t = PT_DSTW;
@ -1979,6 +2046,13 @@ void update_particles_i(pixel *vid, int start, int inc)
else s = 0; else s = 0;
} }
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 (s) { // particle type change occurred
if (t==PT_ICEI||t==PT_LAVA) if (t==PT_ICEI||t==PT_LAVA)
parts[i].ctype = parts[i].type; parts[i].ctype = parts[i].type;