Changeset a99a29ac in sasview for DataLoader


Ignore:
Timestamp:
Oct 8, 2009 2:17:44 PM (15 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
cfbcb6a
Parents:
ac13512
Message:

compute volume fix for discriminant

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/invariant.py

    rac13512 ra99a29ac  
    104104        if len(data.x)<=1 or len(data.y)<=1 or len(data.x)!=len(data.y)\ 
    105105                or len(data.x)!= len(data.dxl): 
    106             print "" 
     106            
    107107            msg = "x, dxl, and y must be have the same length and greater than 1" 
    108108            raise ValueError,msg 
     
    132132                for k = q_star/(2*(pi*|contrast|)**2) 
    133133                we get 2 values of volume: 
    134                      volume1 = (1- sqrt(1+ 4*k))/2 
    135                      volume2 = (1+ sqrt(1+ 4*k))/2 
     134                     volume1 = (1- sqrt(1- 4*k))/2 
     135                     volume2 = (1+ sqrt(1- 4*k))/2 
    136136                     
    137             the result returned will be 0<volume <1 or None 
     137            the result returned will be 0<= volume <= 1 or None 
    138138             
    139139            @param contrast: contrast value provides by the user of type float 
     
    155155        #compute intermediate constant 
    156156        k =  self.q_star /(2*(math.pi* math.fabs(float(contrast)))**2) 
    157         # compute the volume 
    158         volume1 = 0.5 *(1 - math.sqrt(1 + 4*k)) 
    159         volume2 = 0.5 *(1 + math.sqrt(1 + 4*k)) 
    160         print "volume1",volume1 
    161         print "volume2",volume2 
    162         print 
    163         if 0< volume1< 1: 
    164             return volume1 
    165         elif 0< volume2< 1:  
    166             return volume2  
    167         return  
     157        #check discriminant value 
     158        discrim= 1 - 4*k 
     159        if discrim < 0: 
     160            return  
     161        elif discrim ==0: 
     162            volume = 1/2 
     163            return volume 
     164        else: 
     165            # compute the volume 
     166            volume1 = 0.5 *(1 - math.sqrt(discrim)) 
     167            volume2 = 0.5 *(1 + math.sqrt(discrim)) 
     168            print "volume1",volume1 
     169            print "volume2",volume2 
     170            if 0<= volume1<= 1: 
     171                return volume1 
     172            elif 0<= volume2<= 1:  
     173                return volume2  
     174            return  
    168175     
    169176    def _getSurface(self, pConst, volume=None): 
Note: See TracChangeset for help on using the changeset viewer.