Particle detection problem

  • xx_mortekai_xx
    21st Mar 2012 Member 0 Permalink
    IM trying to code fusion between deuterium and tritium when pressure and temperature gets high enough.  For testing and simplicity, the D and T are in liquid form, and the pressure is only 5, and either of the substances need to be just over 300 degrees.  When these conditions are met, helium plasma (in the form of NBLE) should be created, as should a neutron, both created from the original two particles.

    However, I am having some issue getting it to work, and am requesting help.  right now, it only works sporadically, and the tritium seems to only want to react when it is completely surrounded by deuterium. (and, yes, it is based on water.  It IS water, just super heavy water.)

    Here is what I have so far:

    int update_TRIW(UPDATE_FUNC_ARGS) {
    int r, rx, ry;


    for (rx=-2; rx<3; rx++)
    for (ry=-2; ry<3; ry++)
    if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx ry))
    {
    r = pmap[y+ry][x+rx];
    if (!r)
    continue;
    }
    if (((r&0xFF)==PT_RBDM(r&0xFF)==PT_LRBD) && (legacy_enableparts[i].temp>(273.15f+12.0f)) && 1>(rand()%500))
    {
    part_change_type(i,x,y,PT_FIRE);
    parts[i].life = 4;
    parts[i].ctype = PT_TRIW;
    }
    if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){
    kill_part(r>>8);
    if(1>(rand()%150)){
    kill_part(i);
    return 1;
    }
    }
    if (((parts[r>>8].type==PT_DEUT) && (pv[y/CELL][x/CELL] > 5.0f) && (parts[i].temp > 600.0parts[r>>8].temp > 600.0)))
    {
    part_change_type(i , x, y, PT_PLSM);
               parts[i].ctype = PT_NBLE;
               parts[i].temp = MAX_TEMP;
               pv[y/CELL][x/CELL] += 1;
    part_change_type(r>>8, x+rx, y+ry, PT_NEUT);
    parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx;
    parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy;
    }
    return 0;
    }

     
  • vanquish349
    21st Mar 2012 Member 0 Permalink
    this line

    if ((parts[r>>8].type==PT_DEUT) && (pv[y/CELL][x/CELL] > 5.0f) && (parts[i].temp > 600.0parts[r>>8].temp > 600.0))

    should be

    if (((parts[r>>8].type==PT_DEUT) && (pv[y/CELL][x/CELL] > 5.0f) && (parts[i].temp > 600.0 ) && (parts[r>>8].temp > 600.0))


    tell me if it still doesn't work.
  • xx_mortekai_xx
    21st Mar 2012 Member 0 Permalink
    Actually, I turned both the reactants into gasses, and they work fine. Also, where you inserted the && I had , it just didn't show up for some reason. Thanks for your help.