Ignore:
Timestamp:
Apr 6, 2009, 12:30:29 PM (15 years ago)
Author:
garnier
Message:

update processes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/hadronic/models/neutron_hp/src/G4NeutronHPLegendreStore.cc

    r819 r962  
    2828// A prototype of the low energy neutron transport model.
    2929//
     30// 080612 SampleDiscreteTwoBody contribution from Benoit Pirard and Laurent Desorgher (Univ. Bern) #3
     31//
    3032#include "G4NeutronHPLegendreStore.hh"
    3133#include "G4NeutronHPVector.hh"
     
    3436#include "Randomize.hh"
    3537#include <iostream>
     38
     39
     40
     41//080612TK contribution from Benoit Pirard and Laurent Desorgher (Univ. Bern) #3
     42G4double G4NeutronHPLegendreStore::SampleDiscreteTwoBody (G4double anEnergy)
     43{
     44  G4double result;
     45 
     46  G4int i0;
     47  G4int low(0), high(0);
     48  G4NeutronHPFastLegendre theLeg;
     49  for (i0=0; i0<nEnergy; i0++)
     50  {
     51    high = i0;
     52    if(theCoeff[i0].GetEnergy()>anEnergy) break;
     53  }
     54  low = std::max(0, high-1);
     55  G4NeutronHPInterpolator theInt;
     56  G4double x, x1, x2;
     57  x = anEnergy;
     58  x1 = theCoeff[low].GetEnergy();
     59  x2 = theCoeff[high].GetEnergy();
     60  G4double theNorm = 0;
     61  G4double try01=0, try02=0;
     62  G4double max1, max2, costh;
     63  max1 = 0; max2 = 0;
     64  G4int l,m;
     65  for(i0=0; i0<601; i0++)
     66  {
     67      costh = G4double(i0-300)/300.;
     68      try01 = 0.5;
     69      for(m=0; m<theCoeff[low].GetNumberOfPoly() ; m++)
     70      { 
     71          l=m+1;
     72          try01 += (2.*l+1)/2.*theCoeff[low].GetCoeff(m)*theLeg.Evaluate(l, costh);
     73      }
     74      if(try01>max1) max1=try01;
     75      try02 = 0.5;
     76      for(m=0; m<theCoeff[high].GetNumberOfPoly() ; m++)
     77      {
     78          l=m+1;
     79          try02 += (2.*l+1)/2.*theCoeff[high].GetCoeff(m)*theLeg.Evaluate(l, costh);
     80      }
     81      if(try02>max2) max2=try02;
     82  }
     83  theNorm = theInt.Interpolate(theManager.GetScheme(high), x, x1, x2, max1, max2);
     84 
     85  G4double value, random;
     86  G4double v1, v2;
     87  do
     88  {
     89    v1 = 0.5;
     90    v2 = 0.5;
     91    result = 2.*G4UniformRand()-1.;
     92    for(m=0; m<theCoeff[low].GetNumberOfPoly() ; m++)
     93    {
     94        l=m+1; 
     95        G4double legend = theLeg.Evaluate(l, result); // @@@ done to avoid optimization error on SUN
     96        v1 += (2.*l+1)/2.*theCoeff[low].GetCoeff(m)*legend;
     97    }
     98    for(m=0; m<theCoeff[high].GetNumberOfPoly() ; m++)
     99    {   
     100        l=m+1;
     101        G4double legend = theLeg.Evaluate(l, result); // @@@ done to avoid optimization error on SUN
     102        v2 += (2.*l+1)/2.*theCoeff[high].GetCoeff(m)*legend;
     103    }
     104    // v1 = std::max(0.,v1); // Workaround in case one of the distributions is fully non-physical.
     105    // v2 = std::max(0.,v2);
     106    value = theInt.Interpolate(theManager.GetScheme(high), x, x1, x2, v1, v2);
     107    random = G4UniformRand();
     108    if(0>=theNorm) break; // Workaround for negative cross-section values. @@@@ 31 May 2000
     109  }
     110  while(random>value/theNorm);
     111
     112  return result;
     113}
     114
     115
    36116
    37117G4double G4NeutronHPLegendreStore::SampleMax (G4double anEnergy)
Note: See TracChangeset for help on using the changeset viewer.