diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 1d24d2b00..730e5f157 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -2662,14 +2662,17 @@ void Simulation::update_particles_i(int start, int inc) 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)); + 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 pt = (c_heat+parts[i].temp)/(h_count+1); -#endif 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 @@ -2682,29 +2685,93 @@ void Simulation::update_particles_i(int start, int inc) s = 1; if (ctemph>ptransitions[t].thv&&ptransitions[t].tht>-1) { // 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) t = ptransitions[t].tht; +#endif else if (t==PT_ICEI) { - if (parts[i].ctype>0&&parts[i].ctype274.0f) t = PT_WATR; else s = 0; } 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; else t = PT_WTRV; +#endif } else s = 0; } else if (ctempl-1) { // particle type change due to low temperature +#ifdef REALISTIC + float dbt = ctempl - pt; if (ptransitions[t].tlt!=PT_NUM) - t = ptransitions[t].tlt; + { + 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) + t = ptransitions[t].tlt; +#endif else if (t==PT_WTRV) { if (pt<273.0f) t = PT_RIME; else t = PT_DSTW; @@ -2736,6 +2803,13 @@ 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) parts[i].ctype = parts[i].type; @@ -3502,6 +3576,11 @@ Simulation::Simulation(): memcpy(ptypes, ptypesT, elementCount * sizeof(part_type)); free(ptypesT); + int latentCount; + unsigned int * platentT = LoadLatent(latentCount); + memcpy(platent, platentT, latentCount * sizeof(unsigned int)); + free(platentT); + int transitionCount; part_transition * ptransitionsT = LoadTransitions(transitionCount); memcpy(ptransitions, ptransitionsT, sizeof(part_transition) * transitionCount); diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h index 3139b7777..125837351 100644 --- a/src/simulation/Simulation.h +++ b/src/simulation/Simulation.h @@ -140,6 +140,7 @@ public: Air * air; part_type ptypes[PT_NUM]; + unsigned int platent[PT_NUM]; part_transition ptransitions[PT_NUM]; wall_type wtypes[UI_WALLCOUNT]; gol_menu gmenu[NGOL]; diff --git a/src/simulation/SimulationData.cpp b/src/simulation/SimulationData.cpp index e53349185..7022b93b8 100644 --- a/src/simulation/SimulationData.cpp +++ b/src/simulation/SimulationData.cpp @@ -358,6 +358,178 @@ part_type * LoadElements(int & elementCount) return ptypesT; } +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, + /* 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, + }; + elementCount = PT_NUM; + unsigned int * platentT = (unsigned int*)malloc(PT_NUM*sizeof(unsigned int)); + memcpy(platentT, platent, PT_NUM*sizeof(unsigned int)); + return platentT; +} + part_transition * LoadTransitions(int & transitionCount) { #define IPL -257.0f diff --git a/src/simulation/SimulationData.h b/src/simulation/SimulationData.h index 1e1c455ee..03c491af5 100644 --- a/src/simulation/SimulationData.h +++ b/src/simulation/SimulationData.h @@ -148,6 +148,8 @@ menu_section * LoadMenus(int & menuCount); part_type * LoadElements(int & elementCount); +unsigned int * LoadLatent(int & elementCount); + part_transition * LoadTransitions(int & transitionCount); #endif /* SIMULATIONDATA_H_ */