diff options
Diffstat (limited to 'src/simulation/Simulation.cpp')
| -rw-r--r-- | src/simulation/Simulation.cpp | 87 |
1 files changed, 83 insertions, 4 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 1d24d2b..730e5f1 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].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; 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; parts[i].ctype = PT_NONE; parts[i].life = 0; +#endif } } - else if (pt>274.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<ptransitions[t].tlv&&ptransitions[t].tlt>-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); |
