Пример #1
0
    def update_Mix(self):
        kwds = dict(Vfrac=self.Vfrac, #vfrac because don't want it to reset to default
                    solutematerial=self.Material1,
                    solventmaterial=self.Material2
                    )
        
        if self.MixingStyle=='MG (root)':
            self.Mix=MG(**kwds) 

        elif self.MixingStyle=='Bruggeman (root)':
            self.Mix=Bruggeman(**kwds)

        elif self.MixingStyle=='QCACP (root)':
            self.Mix=QCACP(**kwds)

        elif self.MixingStyle=='MG Garcia':
            self.Mix=MG_Mod(**kwds)
            
        elif self.MixingStyle=='LinearSum':
            self.Mix=LinearSum(**kwds)
            
        # I think because I'm delegating mixedarray, but for some reason DoubleMixer.__init__
        # trigger doesn't hook up right.  Should not have to do this, but doesn't
        # cost much extra so don't mess with it.  Exhausted all posib
        self.Mix.update_mix()
Пример #2
0
    def update_Mix(self):
        kwds = dict(
            Vfrac=self.Vfrac,  #vfrac because don't want it to reset to default
            solutematerial=self.Material1,
            solventmaterial=self.Material2)

        if self.MixingStyle == 'MG (root)':
            self.Mix = MG(**kwds)

        elif self.MixingStyle == 'Bruggeman (root)':
            self.Mix = Bruggeman(**kwds)

        elif self.MixingStyle == 'QCACP (root)':
            self.Mix = QCACP(**kwds)

        elif self.MixingStyle == 'MG Garcia':
            self.Mix = MG_Mod(**kwds)

        elif self.MixingStyle == 'LinearSum':
            self.Mix = LinearSum(**kwds)

        # I think because I'm delegating mixedarray, but for some reason DoubleMixer.__init__
        # trigger doesn't hook up right.  Should not have to do this, but doesn't
        # cost much extra so don't mess with it.  Exhausted all posib
        self.Mix.update_mix()
Пример #3
0
 def _Mix_default(self):
     return LinearSum(solutematerial=self.Material1,
                      solventmaterial=self.Material2)
Пример #4
0
class CompositeMaterial(BasicMaterial):
    """Still inherits basic traits like earray, narray and how they are 
    interrelated
    """
    selectedtree = Instance(HasTraits, SHARED_TREE)

    Material1 = Instance(IMaterial)
    Material2 = Instance(IMaterial)  #Make these classes later

    Mix = Instance(IMixer)
    MixingStyle = Enum('MG Garcia', 'Bruggeman (root)', 'QCACP (root)',
                       'MG (root)', 'LinearSum')
    Vfrac = DelegatesTo('Mix')  #Coordinates with parameter in mixer
    earray = DelegatesTo('Mix', prefix='mixedarray')

    selectmat1 = Button
    selectmat2 = Button

    mixgroup = Group(VGroup(
        Item('MixingStyle', label='Mixing Method', show_label=False),
        Item('Mix',
             editor=InstanceEditor(),
             style='custom',
             label='Mixing Parameters',
             show_label=False),
    ),
                     label='Mixing Parameters')

    compmatgroup = Group(HGroup(
        Item('mviewbutton', label='Show Composite Material', show_label=False),
        Item('selectmat1', label='Change Material1', show_label=False),
        Item('selectmat2', label='Change Material2', show_label=False),
        Item('mat_name', label='Material Name', show_label=False)),
                         Tabbed(
                             Item('Material1',
                                  editor=InstanceEditor(),
                                  style='custom',
                                  show_label=False),
                             Item('Material2',
                                  editor=InstanceEditor(),
                                  style='custom',
                                  show_label=False),
                         ),
                         label='Materials')

    traits_view = View(Include('compmatgroup'),
                       Include('mixgroup'),
                       resizable=True,
                       buttons=OKCancelButtons)

    def __init__(self, *args, **kwargs):
        super(CompositeMaterial, self).__init__(*args, **kwargs)
        self.Mix.update_mix()

    def simulation_requested(self):
        out = super(CompositeMaterial, self).simulation_requested()

        out.update({
            'material1': self.Material1.simulation_requested(),
            'material2': self.Material2.simulation_requested(),
            'mixing_style': self.MixingStyle,
            'Vfrac': self.Vfrac
        })
        return out

    def _Material1_default(self):
        return Sellmeir()

    def _Material2_default(self):
        return Dispwater()

    def _Mix_default(self):
        return MG_Mod(solutematerial=self.Material1,
                      solventmaterial=self.Material2)

    def _mat_name_default(self):
        return self.Material1.mat_name + '  IN  ' + self.Material2.mat_name

    def update_matname(self):
        if pconfig.AUTONAME:
            self.mat_name = '%s  IN  %s' % (self.Material1.mat_name,
                                            self.Material2.mat_name)

    def _MixingStyle_changed(self):
        self.update_Mix()

    def _Material1_changed(self):
        # This should be a property, right?  Or a separate attribute?
        self.update_matname()
        self.Mix.solutematerial = self.Material1
        self.redraw_requested()

    def _Material2_changed(self):
        self.update_matname()
        self.Mix.solventmaterial = self.Material2
        self.redraw_requested()

    def update_Mix(self):
        kwds = dict(
            Vfrac=self.Vfrac,  #vfrac because don't want it to reset to default
            solutematerial=self.Material1,
            solventmaterial=self.Material2)

        if self.MixingStyle == 'MG (root)':
            self.Mix = MG(**kwds)

        elif self.MixingStyle == 'Bruggeman (root)':
            self.Mix = Bruggeman(**kwds)

        elif self.MixingStyle == 'QCACP (root)':
            self.Mix = QCACP(**kwds)

        elif self.MixingStyle == 'MG Garcia':
            self.Mix = MG_Mod(**kwds)

        elif self.MixingStyle == 'LinearSum':
            self.Mix = LinearSum(**kwds)

        # I think because I'm delegating mixedarray, but for some reason DoubleMixer.__init__
        # trigger doesn't hook up right.  Should not have to do this, but doesn't
        # cost much extra so don't mess with it.  Exhausted all posib
        self.Mix.update_mix()

    # Change Solute
    def _selectmat1_fired(self):
        """Used to select material.  The exceptions are if the user returns nothing or selects a folder rather than an object for example"""
        self.selectedtree.configure_traits(kind='modal')
        try:
            selected_adapter = self.selectedtree.current_selection
            selected_adapter.populate_object()
            self.Material1 = selected_adapter.matobject
        except (TypeError, AttributeError):
            pass

    # Change Solvent
    def _selectmat2_fired(self):
        self.selectedtree.configure_traits(kind='modal')
        try:
            selected_adapter = self.selectedtree.current_selection
            selected_adapter.populate_object()
            self.Material2 = selected_adapter.matobject
        except (TypeError, AttributeError):
            pass

    def allview_requested(self, prefix=None):
        """Dielectric for self, M1, M2
        """
        out = super(CompositeMaterial,
                    self).allview_requested()  #<-- no prefix
        out.update(self.Material1.allview_requested(prefix='M1'))
        out.update(self.Material2.allview_requested(prefix='M2'))

        if prefix:
            out = dict(('%s.%s' % (prefix, k), v) for k, v in out.items())
        return out
Пример #5
0
class CompositeMaterial(BasicMaterial):
    """Still inherits basic traits like earray, narray and how they are 
    interrelated
    """
    selectedtree = Instance(HasTraits, SHARED_TREE)  

    Material1=Instance(IMaterial)
    Material2=Instance(IMaterial)   #Make these classes later    

    Mix=Instance(IMixer)
    MixingStyle=Enum('MG Garcia', 
                     'Bruggeman (root)', 
                     'QCACP (root)',
                     'MG (root)',
                     'LinearSum'
                     )
    Vfrac=DelegatesTo('Mix')	#Coordinates with parameter in mixer
    earray=DelegatesTo('Mix', prefix='mixedarray')

    selectmat1=Button 
    selectmat2=Button

    mixgroup=Group(   
        VGroup(
           Item('MixingStyle', label='Mixing Method', show_label=False),
           Item('Mix', editor=InstanceEditor(), style='custom', 
                label='Mixing Parameters', show_label=False ),        
               ), 
        label='Mixing Parameters')     

    compmatgroup=Group(
                    HGroup(
                           Item('mviewbutton', label='Show Composite Material', show_label=False),
                           Item('selectmat1', label='Change Material1', show_label=False), 
                           Item('selectmat2', label='Change Material2', show_label=False),
                           Item('mat_name', label='Material Name', show_label=False)
                           ),
                       Tabbed( 
                           Item('Material1', editor=InstanceEditor(), 
                                style='custom', show_label=False),
                           Item('Material2', editor=InstanceEditor(),
                                style='custom', show_label=False),
                           ),

                       label='Materials')

    traits_view=View(
                     Include('compmatgroup' ),
                     Include('mixgroup'), 
                     resizable=True, buttons=OKCancelButtons)

    def __init__(self, *args, **kwargs):
        super(CompositeMaterial, self).__init__(*args, **kwargs)
        self.Mix.update_mix()


    def simulation_requested(self):
        out = super(CompositeMaterial, self).simulation_requested()
        
        out.update({
            'material1':self.Material1.simulation_requested(),
            'material2':self.Material2.simulation_requested(), 
            'mixing_style':self.MixingStyle,
            'Vfrac':self.Vfrac})
        return out

    def _Material1_default(self): 
        return Sellmeir()

    def _Material2_default(self): 	
        return Dispwater()

    def _Mix_default(self): 
        return MG_Mod(solutematerial=self.Material1,
                      solventmaterial=self.Material2)

    def _mat_name_default(self): 
        return self.Material1.mat_name + '  IN  ' + self.Material2.mat_name

    def update_matname(self):
        if pconfig.AUTONAME:
            self.mat_name = '%s  IN  %s' % (self.Material1.mat_name, self.Material2.mat_name)

    def _MixingStyle_changed(self): 
        self.update_Mix() 

    def _Material1_changed(self): 
        # This should be a property, right?  Or a separate attribute?
        self.update_matname()
        self.Mix.solutematerial = self.Material1
        self.redraw_requested()

    def _Material2_changed(self): 
        self.update_matname()
        self.Mix.solventmaterial = self.Material2
        self.redraw_requested()        

    def update_Mix(self):
        kwds = dict(Vfrac=self.Vfrac, #vfrac because don't want it to reset to default
                    solutematerial=self.Material1,
                    solventmaterial=self.Material2
                    )
        
        if self.MixingStyle=='MG (root)':
            self.Mix=MG(**kwds) 

        elif self.MixingStyle=='Bruggeman (root)':
            self.Mix=Bruggeman(**kwds)

        elif self.MixingStyle=='QCACP (root)':
            self.Mix=QCACP(**kwds)

        elif self.MixingStyle=='MG Garcia':
            self.Mix=MG_Mod(**kwds)
            
        elif self.MixingStyle=='LinearSum':
            self.Mix=LinearSum(**kwds)
            
        # I think because I'm delegating mixedarray, but for some reason DoubleMixer.__init__
        # trigger doesn't hook up right.  Should not have to do this, but doesn't
        # cost much extra so don't mess with it.  Exhausted all posib
        self.Mix.update_mix()

    # Change Solute
    def _selectmat1_fired(self): 
        """Used to select material.  The exceptions are if the user returns nothing or selects a folder rather than an object for example"""
        self.selectedtree.configure_traits(kind='modal')
        try:
            selected_adapter=self.selectedtree.current_selection
            selected_adapter.populate_object()
            self.Material1 = selected_adapter.matobject
        except (TypeError, AttributeError):  
            pass        
        

    # Change Solvent
    def _selectmat2_fired(self): 
        self.selectedtree.configure_traits(kind='modal')
        try:
            selected_adapter=self.selectedtree.current_selection
            selected_adapter.populate_object()
            self.Material2 = selected_adapter.matobject
        except (TypeError, AttributeError):  
            pass


    def allview_requested(self, prefix=None):
        """Dielectric for self, M1, M2
        """
        out = super(CompositeMaterial, self).allview_requested() #<-- no prefix
        out.update(self.Material1.allview_requested(prefix='M1'))
        out.update(self.Material2.allview_requested(prefix='M2'))
        
        if prefix:
            out = dict( ('%s.%s'%(prefix, k), v) for k,v in out.items() )              
        return out