Changeset 8b677ec in sasview for sansmodels/src/sans/models


Ignore:
Timestamp:
Sep 8, 2009 11:02:19 AM (15 years ago)
Author:
Jae Cho <jhjcho@…>
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:
4785dec
Parents:
ec38f27
Message:

Corrections are made after multiplicationmodel unittest

Location:
sansmodels/src/sans/models
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/MultiplicationModel.py

    r59930f3 r8b677ec  
    66class MultiplicationModel(BaseComponent): 
    77    """ 
    8         Use for P(Q)*S(Q); function call maut be in order of P(Q) and then S(Q). 
    9         Perform multplication of two models. 
     8        Use for P(Q)*S(Q); function call must be in order of P(Q) and then S(Q). 
     9        Perform multiplication of two models. 
    1010        Contains the models parameters combined. 
    1111    """ 
     
    1616        ## Setting  model name model description 
    1717        self.description="" 
    18         if  model1.name != "NoStructure"and  model2.name != "NoStructure": 
     18        if  model1.name != "NoStructure" and  model2.name != "NoStructure": 
    1919             self.name = model1.name +" * "+ model2.name 
    2020             self.description= self.name+"\n" 
    21              self.description +="see %s description and %s description"%( model1.name, 
    22                                                                          model2.name ) 
     21             self.fill_description(model1, model2) 
    2322        elif  model2.name != "NoStructure": 
    2423            self.name = model2.name 
     
    4746        for item in self.model2.orientation_params: 
    4847            if not item in self.orientation_params: 
    49                 if item != 'effect_radius': 
    50                     self.orientation_params.append(item) 
     48                self.orientation_params.append(item) 
    5149                 
    5250         
     
    7472             
    7573        for name , value in self.model2.dispersion.iteritems(): 
    76             # S(Q) has only 'radius' for dispersion. 
     74            ## All S(Q) has only 'effect_radius' for dispersion which  
     75            #    will not be allowed for now. 
    7776            if not name in self.dispersion.keys(): 
    7877                if name != 'effect_radius': 
     
    9392        for name , value in self.model2.params.iteritems(): 
    9493            if not name in self.params.keys(): 
     94                #effect_radius is not treated as a parameter anymore. 
    9595                if name != 'effect_radius':  
    9696                    self.params[name]= value 
     
    105105             
    106106        for name , detail in self.model2.details.iteritems(): 
    107             if not name in self.details.keys()and name != 'effect_radius': #???? 
    108                 self.details[name]= detail 
     107            if not name in self.details.keys():  
     108                if name != 'effect_radius':  
     109                    self.details[name]= detail 
    109110                 
    110111    def setParam(self, name, value): 
     
    155156        for item in self.model1.fixed: 
    156157            self.fixed.append(item) 
    157              
    158         for item in self.model2.fixed: 
    159             if not item in self.fixed: 
    160                 self.fixed.append(item) 
     158        #S(Q) should not have fixed items for P*S for now. 
     159        #for item in self.model2.fixed: 
     160        #    if not item in self.fixed: 
     161        #        self.fixed.append(item) 
     162 
    161163        self.fixed.sort() 
    162164                 
     
    180182            @return: DAB value 
    181183        """ 
     184         
    182185        #Reset radius of model2 just before the run 
    183186        effective_radius = None     
     
    200203            #There is no dispersion for the structure factors(S(Q)).  
    201204            #ToDo: need to decide whether or not the dispersion for S(Q) has to be considered for P*S.   
    202             elif parameter in self.model2.dispersion.keys(): 
    203                 if item != 'effect_radius': 
    204                     value= self.model2.set_dispersion(parameter, dispersion) 
     205            #elif parameter in self.model2.dispersion.keys(): 
     206            #    if item != 'effect_radius': 
     207            #        value= self.model2.set_dispersion(parameter, dispersion) 
    205208            self._set_dispersion() 
    206209            return value 
     
    208211            raise  
    209212 
    210  
    211      
     213    def fill_description(self, model1, model2): 
     214        """ 
     215            Fill the description for P(Q)*S(Q) 
     216        """ 
     217        description = "" 
     218        description += "Note:1) The effect_radius (effective radius) of %s \n"% (model2.name) 
     219        description +="             is automatically calculated from size parameters (radius...).\n" 
     220        description += "         2) For non-spherical shape, this approximation is valid \n" 
     221        description += "            only for highly dilute systems. Thus, use it at your own risk.\n" 
     222        description +="See %s description and %s description \n"%( model1.name,model2.name ) 
     223        description += "        for details." 
     224        self.description += description 
     225     
  • sansmodels/src/sans/models/c_extensions/HayterMSA.c

    r42ae1d9 r8b677ec  
    1515 * @return: function value 
    1616 */ 
     17 
    1718double HayterMSA_analytical_1D(HayterMSAParameters *pars, double q) { 
    1819        double dp[6]; 
    1920        //Hayer takes diameter. 
    20         dp[0] = 2.0*pars->effect_radius; 
     21        dp[0] = 2.0 * pars->effect_radius; 
    2122        dp[1] = pars->charge; 
    22         dp[1] = pars->volfraction; 
     23        dp[2] = pars->volfraction; 
    2324        dp[3] = pars->temperature; 
    2425        dp[4] = pars->saltconc; 
  • sansmodels/src/sans/models/c_extensions/HayterMSA.h

    r5eb9154 r8b677ec  
    5050} HayterMSAParameters; 
    5151 
    52  
    53  
    5452/// 1D scattering function 
    5553double HayterMSA_analytical_1D(HayterMSAParameters *pars, double q); 
  • sansmodels/src/sans/models/c_models/HayterMSA.cpp

    r42ae1d9 r8b677ec  
    9191        HayterMSAParameters dp; 
    9292        // Fill parameter array 
    93         dp.effect_radius      = 2.0*effect_radius(); 
     93        dp.effect_radius      = effect_radius(); 
    9494        dp.charge      = charge(); 
    9595        dp.volfraction = volfraction(); 
     
    108108        // Loop over radius weight points 
    109109        for(int i=0; i<weights_rad.size(); i++) { 
    110                 dp.effect_radius = 2.0*weights_rad[i].value; 
     110                dp.effect_radius = weights_rad[i].value; 
    111111 
    112                                         double _ptvalue = weights_rad[i].weight 
    113                                                 * HayterMSA_analytical_2DXY(&dp, qx, qy); 
    114                                         sum += _ptvalue; 
     112                double _ptvalue = weights_rad[i].weight 
     113                        * HayterMSA_analytical_2DXY(&dp, qx, qy); 
     114                sum += _ptvalue; 
    115115 
    116                                         norm += weights_rad[i].weight; 
     116                norm += weights_rad[i].weight; 
    117117        } 
    118118        // Averaging in theta needs an extra normalization 
Note: See TracChangeset for help on using the changeset viewer.