Demo entry 2148725

strawman

   

Submitted by anonymous on Jul 10, 2015 at 00:52
Language: C++. Code size: 853 Bytes.

int myZoneStart, myZoneEnd;
double rxnCrossSection[];

// Loop over my zones
for (int i = myZoneStart; i < myZoneEnd; i++)
  {
    // Caclualte all the reaction cross sections
    for (int j = 0; j < numReactions; j++)
      {
	rxnCrossSection[j] = calcRxnCrossSection(density[i],
						 temperature[i],
						 abundances[i],
						 j);
      }
    // Loop over all isotopes
    for (int k = 0; k < numIsotopes; k++)
      {
	// Only calculate those isotopes in this zone
	if (isotopeInCell(k,i))
	  {
	    // Loop over all reactions
	    for (int j =0; j < numReactions; j++)
	      {
		// add losses and gains due to reactions
		abundance_change[k] -= reactants[j,k]*rxnCrossSection[j];
		abundance_change[k] += products[j,k]*rxnCrossSection[j];
	      }

	    // update the abundances
	    abundances[i][k] += abundance_change[k]*dt
	  }
      }
  }

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).