Source code for fudge.gnds.reactions.reaction

# <<BEGIN-copyright>>
# <<END-copyright>>

"""
This module contains the reaction class.
"""

from xData import standards as standardsModule

from fudge.core.utilities import brb
from fudge.core.utilities import fudgeExceptions

from fudge.gnds.channelData import Q as QModule
from fudge.gnds.reactionData import availableEnergy as availableEnergyModule
from fudge.gnds.reactionData import availableMomentum as availableMomentumModule
from fudge.gnds.reactionData.doubleDifferentialCrossSection.chargedParticleElastic import CoulombPlusNuclearElastic as CoulombPlusNuclearElasticModule

from fudge.gnds.productData.distributions import angular as angularModule

from . import base as baseModule

__metaclass__ = type

[docs]class reaction( baseModule.base_reaction ) : """This is the class for a normal gnds reaction.""" moniker = 'reaction' ancestryMembers = baseModule.base_reaction.ancestryMembers + ( 'availableEnergy', 'availableMomentum' ) def __init__( self, outputChannel, ENDF_MT, documentation = None, label = None, process = None ) : """ Creates a new reaction object. Reaction is two-body or uncorrelated-body, depending on the outputChannel type. This class is only meant to be used for 'distinct' reactions (distinct reactions do not overlap any other reactions; altogether they sum up to total). To store a sum over these distinct reactions, use the product class. """ baseModule.base_reaction.__init__( self, outputChannel, ENDF_MT, documentation, label = label, process = process ) self.availableEnergy = availableEnergyModule.component( ) self.availableEnergy.setAncestor( self ) self.availableMomentum = availableMomentumModule.component( ) self.availableMomentum.setAncestor( self ) def __eq__(self, other): if (not baseModule.isGNDSReaction( other )): return False selfParent, otherParent = self.getReactionSuite( ), other.getReactionSuite( ) return( ( selfParent.projectile == otherParent.projectile ) and ( selfParent.target == otherParent.target ) and ( self.outputChannel == other.outputChannel ) ) def __cmp__( self, other ) : """Test if self is <, == or > other.""" if( not baseModule.isGNDSReaction( other ) ) : raise fudgeExceptions.FUDGE_Exception( "Other not an reaction object." ) selfParent, otherParent = self.getReactionSuite( ), other.getReactionSuite( ) if( selfParent.projectile < otherParent.projectile ) : return( -1 ) if( selfParent.projectile > otherParent.projectile ) : return( 1 ) if( selfParent.target < otherParent.target ) : return( -1 ) if( selfParent.target > otherParent.target ) : return( 1 ) if( self.outputChannel < other.outputChannel ) : return( -1 ) if( self.outputChannel > other.outputChannel ) : return( 1 ) return( 0 ) def __str__( self ) : return( str( self.outputChannel ) )
[docs] def getThreshold( self, unit ) : Q = self.getQ( unit = unit, final = False ) if( Q >= 0. ) : return( 0. ) reactionSuite = self.getReactionSuite( ) projectile = reactionSuite.PoPs[reactionSuite.projectile] projectileMass = projectile.mass[0].float( 'amu' ) targetID = reactionSuite.target if( targetID in reactionSuite.PoPs.aliases ) : targetID = reactionSuite.PoPs[targetID].pid target = reactionSuite.PoPs[targetID] try: targetMass = target.mass[0].float( 'amu' ) except IndexError: targetMass = target.getMass('amu') return( -Q * ( 1. + projectileMass / targetMass ) )
[docs] def isBasicReaction( self ) : return( True )
[docs] def isCompleteReaction( self ) : return( True )
[docs] def processCoulombPlusNuclearMuCutoff( self, style ) : for doubleDifferentialCrossSection in self.doubleDifferentialCrossSection : if( isinstance( doubleDifferentialCrossSection, CoulombPlusNuclearElasticModule.form ) ) : crossSection, angular = doubleDifferentialCrossSection.processCoulombPlusNuclearMuCutoff( style ) self.crossSection.add( crossSection ) product = self.outputChannel[0] if( product.pid != doubleDifferentialCrossSection.pid ) : raise Exception( 'First product out not one described in doubleDifferentialCrossSection data.' ) product.distribution.add( angularModule.twoBodyForm( style.label, standardsModule.frames.centerOfMassToken, angular ) ) residual = self.outputChannel[1] residual.distribution.add( angularModule.twoBodyForm( style.label, standardsModule.frames.centerOfMassToken, angularModule.recoil( angular ) ) ) break