diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-18 20:18:37 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-04-18 20:18:37 (GMT) |
| commit | b40f13b66a8661d8698e5fc737c2842dfb73e6f9 (patch) | |
| tree | 1e9fb258cd8bcbba92c14b0ccef4bf6acfd3712a /src/simulation/Simulation.cpp | |
| parent | ff7428fc70385287204832048bcf2f3c72aaabe8 (diff) | |
| download | powder-b40f13b66a8661d8698e5fc737c2842dfb73e6f9.zip powder-b40f13b66a8661d8698e5fc737c2842dfb73e6f9.tar.gz | |
TPT: Added gel - a liquid with variable heat conductivity and viscosity. 8523da398f
Diffstat (limited to 'src/simulation/Simulation.cpp')
| -rw-r--r-- | src/simulation/Simulation.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index fdc94ab..b08398f 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -1175,7 +1175,7 @@ void Simulation::init_can_move() for (rt=1;rt<PT_NUM;rt++) { // weight check, also prevents particles of same type displacing each other - if (ptypes[t].weight <= ptypes[rt].weight) can_move[t][rt] = 0; + if (ptypes[t].weight <= ptypes[rt].weight || rt==PT_GEL) can_move[t][rt] = 0; if (t==PT_NEUT && (ptypes[rt].properties&PROP_NEUTPASS)) can_move[t][rt] = 2; if (t==PT_NEUT && (ptypes[rt].properties&PROP_NEUTABSORB)) @@ -2598,9 +2598,13 @@ void Simulation::update_particles_i(int start, int inc) } } + float gel_scale = 1.0f; + if (t==PT_GEL) + gel_scale = parts[i].tmp*2.55f; + if (!legacy_enable) { - if (y-2 >= 0 && y-2 < YRES && (ptypes[t].properties&TYPE_LIQUID)) {//some heat convection for liquids + if (y-2 >= 0 && y-2 < YRES && (ptypes[t].properties&TYPE_LIQUID) && gel_scale>(rand()%250)) {//some heat convection for liquids r = pmap[y-2][x]; if (!(!r || parts[i].type != (r&0xFF))) { if (parts[i].temp>parts[r>>8].temp) { @@ -2614,19 +2618,19 @@ 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)&&ptypes[t].hconduct) + if (t&&(t!=PT_HSWC||parts[i].life==10)&&(ptypes[t].hconduct*gel_scale)) { float c_Cm = 0.0f; #else - if (t&&(t!=PT_HSWC||parts[i].life==10)&&ptypes[t].hconduct>(rand()%250)) + if (t&&(t!=PT_HSWC||parts[i].life==10)&&(ptypes[t].hconduct*gel_scale)>(rand()%250)) { float c_Cm = 0.0f; #endif if (aheat_enable) { #ifdef REALISTIC - c_heat = parts[i].temp*96.645/ptypes[t].hconduct*fabs(ptypes[t].weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]+273.15f)/256; - c_Cm = 96.645/ptypes[t].hconduct*fabs(ptypes[t].weight) + 100*(pv[y/CELL][x/CELL]+273.15f)/256; + c_heat = parts[i].temp*96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]+273.15f)/256; + c_Cm = 96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight) + 100*(pv[y/CELL][x/CELL]+273.15f)/256; pt = c_heat/c_Cm; pt = restrict_flt(pt, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP); parts[i].temp = pt; @@ -2655,8 +2659,12 @@ void Simulation::update_particles_i(int start, int inc) { surround_hconduct[j] = r>>8; #ifdef REALISTIC - c_heat += parts[r>>8].temp*96.645/ptypes[rt].hconduct*fabs(ptypes[rt].weight); - c_Cm += 96.645/ptypes[rt].hconduct*fabs(ptypes[rt].weight); + 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/ptypes[rt].hconduct*gel_scale*fabs(ptypes[rt].weight); + c_Cm += 96.645/ptypes[rt].hconduct*gel_scale*fabs(ptypes[rt].weight); #else c_heat += parts[r>>8].temp; #endif @@ -2664,13 +2672,17 @@ void Simulation::update_particles_i(int start, int inc) } } #ifdef REALISTIC + if (t==PT_GEL) + gel_scale = parts[i].tmp*2.55f; + else gel_scale = 1.0f; + if (t == PT_PHOT) pt = (c_heat+parts[i].temp*96.645)/(c_Cm+96.645); 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*gel_scale*fabs(ptypes[t].weight))/(c_Cm+96.645/ptypes[t].hconduct*gel_scale*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); + c_heat += parts[i].temp*96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight); + c_Cm += 96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight); parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP); #else pt = (c_heat+parts[i].temp)/(h_count+1); |
