Changeset 1588

Show
Ignore:
Timestamp:
10/11/2005 03:59:16 PM (3 years ago)
Author:
wd15
Message:

Making the example the same as the test

Location:
trunk/examples/levelSet/electroChem
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/levelSet/electroChem/inputSimpleTrenchSystem.py

    r1585 r1588  
    230230     
    231231    from fipy.variables.cellVariable import CellVariable 
     232 
    232233    bulkCatalystVar = CellVariable( 
    233234        name = 'bulk catalyst variable', 
    234235        mesh = mesh, 
    235236        value = catalystConcentration) 
    236      
    237     from fipy.variables.cellVariable import CellVariable 
     237 
    238238    metalVar = CellVariable( 
    239239        name = 'metal variable', 
     
    267267        surfactantVar = catalystVar, 
    268268        distanceVar = distanceVar, 
    269         bulkVar = catalystConcentration, 
     269        bulkVar = bulkCatalystVar, 
    270270        rateConstant = rateConstant0 + rateConstant3 * overpotential**3) 
    271271 
     
    322322    for step in range(numberOfSteps): 
    323323 
    324         if not runAsTest: 
    325             if step % levelSetUpdateFrequency == 0: 
    326                 distanceVar.calcDistanceFunction() 
    327  
    328             extensionVelocityVariable.setValue(depositionRateVariable()) 
     324        if step % levelSetUpdateFrequency == 0: 
     325            distanceVar.calcDistanceFunction() 
     326             
     327        extensionVelocityVariable.setValue(depositionRateVariable()) 
    329328 
    330329        distanceVar.updateOld() 
     
    332331        metalVar.updateOld() 
    333332        bulkCatalystVar.updateOld() 
     333 
    334334        distanceVar.extendVariable(extensionVelocityVariable) 
    335         if not runAsTest: 
    336             dt = cflNumber * cellSize / max(extensionVelocityVariable) 
    337         else: 
    338             dt = 0.1 
     335        dt = cflNumber * cellSize / max(extensionVelocityVariable) 
     336 
    339337        advectionEquation.solve(distanceVar, dt = dt)  
    340338        surfactantEquation.solve(catalystVar, dt = dt) 
     
    342340                            boundaryConditions = metalEquationBCs) 
    343341        bulkCatalystEquation.solve(bulkCatalystVar, dt = dt, 
    344                                       boundaryConditions = catalystBCs) 
     342                                   boundaryConditions = catalystBCs) 
    345343 
    346344        if not runAsTest: 
     
    349347 
    350348    if runAsTest: 
     349         
    351350        import os 
    352         testFile = 'test.gz' 
    353351        import examples.levelSet.electroChem 
    354         import gzip 
    355         filepath = os.path.join(examples.levelSet.electroChem.__path__[0],  
    356                                 testFile) 
    357  
    358         filestream = gzip.open(filepath,'r') 
    359         import cPickle 
    360         testData = cPickle.load(filestream) 
    361         filestream.close() 
    362         print catalystVar.allclose(testData) 
     352        filepath = os.path.join(examples.levelSet.electroChem.__path__[0], 'test.gz') 
     353 
     354        from fipy.tools import dump 
     355        print catalystVar.allclose(dump.read(filepath)) 
     356 
    363357    else: 
    364358        raw_input("finished") 
  • trunk/examples/levelSet/electroChem/inputWriteScriptHowTo.py

    r1587 r1588  
    8282   >>> transferCoefficient = 0.5 
    8383 
    84 properties associated with the accelerator species, 
    85  
    86    >>> rateConstant = 1.76 
    87    >>> overpotentialDependence = -245e-6 
    88    >>> acceleratorDiffusionCoefficient = 1e-9 
     84properties associated with the catalyst species, 
     85 
     86   >>> rateConstant0 = 1.76 
     87   >>> rateConstant3 = -245e-6 
     88   >>> catalystDiffusion = 1e-9 
    8989   >>> siteDensity = 9.8e-6 
    9090    
     
    100100   >>> overpotential = -0.3 
    101101   >>> bulkMetalConcentration = 250. 
    102    >>> bulkAcceleratorConcentration = 5e-3 
    103    >>> initialAcceleratorCoverage = 0. 
     102   >>> catalystConcentration = 5e-3 
     103   >>> catalystCoverage = 0. 
    104104       
    105105parameters obtained from experiments on flat copper electrodes, 
    106106 
    107    >>> constantCurrentDensity = 0.26 
    108    >>> acceleratorDependenceCurrentDensity = 45. 
     107   >>> currentDensity0 = 0.26 
     108   >>> currentDensity1 = 45. 
    109109 
    110110general simulation control parameters, 
     
    211211.. raw:: latex 
    212212 
    213     Create the accelerator surfactant coverage, $\theta$, variable. 
     213    Create the catalyst surfactant coverage, $\theta$, variable. 
    214214 
    215215This variable influences the deposition rate. 
     
    217217   >>> from fipy.models.levelSet.surfactant.surfactantVariable import \ 
    218218   ...     SurfactantVariable 
    219    >>> acceleratorVar = SurfactantVariable( 
    220    ...     name = "accelerator variable", 
    221    ...     value = initialAcceleratorCoverage, 
     219   >>> catalystVar = SurfactantVariable( 
     220   ...     name = "catalyst variable", 
     221   ...     value = catalystCoverage, 
    222222   ...     distanceVar = distanceVar) 
    223223 
    224224.. raw:: latex 
    225225 
    226     Create the bulk accelerator concentration, $c_{\theta}$, 
     226    Create the bulk catalyst concentration, $c_{\theta}$, 
    227227 
    228228in the electrolyte, 
    229229 
    230230   >>> from fipy.variables.cellVariable import CellVariable 
    231    >>> bulkAcceleratorVar = CellVariable( 
    232    ...     name = 'bulk accelerator variable', 
     231   >>> bulkCatalystVar = CellVariable( 
     232   ...     name = 'bulk catalyst variable', 
    233233   ...     mesh = mesh, 
    234    ...     value = bulkAcceleratorConcentration) 
     234   ...     value = catalystConcentration) 
    235235    
    236236Create the bulk metal ion concentration, 
     
    271271    constant, $T$ is the temperature and $\eta$ is the 
    272272    overpotential. The exchange current density is an empirical 
    273     function of accelerator coverage, 
     273    function of catalyst coverage, 
    274274 
    275275    $$ i_0(\theta) = b_0 + b_1 \theta $$ 
     
    279279   >>> expoConstant = -transferCoefficient * faradaysConstant \ 
    280280   ...                / (gasConstant * temperature) 
    281    >>> tmp = acceleratorDependenceCurrentDensity \ 
    282    ...       * acceleratorVar.getInterfaceVar() 
    283    >>> exchangeCurrentDensity = constantCurrentDensity + tmp 
     281   >>> tmp = currentDensity1 \ 
     282   ...       * catalystVar.getInterfaceVar() 
     283   >>> exchangeCurrentDensity = currentDensity0 + tmp 
    284284   >>> expo = numerix.exp(expoConstant * overpotential) 
    285285   >>> currentDensity = expo * exchangeCurrentDensity * metalVar \ 
     
    309309    $$ \dot{\theta} = J v \theta + k c_{\theta}^i (1 - \theta) $$ 
    310310 
    311     where $\theta$ is the coverage of accelerator at the interface, 
     311    where $\theta$ is the coverage of catalyst at the interface, 
    312312    $J$ is the curvature of the interface, $v$ is the normal velocity 
    313313    of the interface, $c_{\theta}^i$ is the concentration of 
    314     accelerator in the bulk at the interface. The value $k$ is given 
     314    catalyst in the bulk at the interface. The value $k$ is given 
    315315    by an empirical function of overpotential, 
    316316 
     
    323323   ...             import AdsorbingSurfactantEquation 
    324324   >>> surfactantEquation = AdsorbingSurfactantEquation( 
    325    ...     surfactantVar = acceleratorVar, 
     325   ...     surfactantVar = catalystVar, 
    326326   ...     distanceVar = distanceVar, 
    327    ...     bulkVar = bulkAcceleratorConcentration, 
    328    ...     rateConstant = rateConstant \ 
    329    ...                    + overpotentialDependence * overpotential**3) 
     327   ...     bulkVar = bulkCatalystVar, 
     328   ...     rateConstant = rateConstant0 \ 
     329   ...                    + rateConstant3 * overpotential**3) 
    330330 
    331331.. raw:: latex 
     
    417417   >>> from fipy.models.levelSet.surfactant.surfactantBulkDiffusionEquation \ 
    418418   ...                 import buildSurfactantBulkDiffusionEquation 
    419    >>> bulkAcceleratorEquation = buildSurfactantBulkDiffusionEquation( 
    420    ...     bulkVar = bulkAcceleratorVar, 
     419   >>> bulkCatalystEquation = buildSurfactantBulkDiffusionEquation( 
     420   ...     bulkVar = bulkCatalystVar, 
    421421   ...     distanceVar = distanceVar, 
    422    ...     surfactantVar = acceleratorVar, 
    423    ...     diffusionCoeff = acceleratorDiffusionCoefficient, 
    424    ...     rateConstant = rateConstant * siteDensity 
     422   ...     surfactantVar = catalystVar, 
     423   ...     diffusionCoeff = catalystDiffusion, 
     424   ...     rateConstant = rateConstant0 * siteDensity 
    425425   ... ) 
    426426 
    427    >>> acceleratorBCs = ( 
     427   >>> catalystBCs = ( 
    428428   ...         FixedValue( 
    429429   ...             mesh.getFacesTop(), 
    430    ...             bulkAcceleratorConcentration 
     430   ...             catalystConcentration 
    431431   ...         ),) 
    432432    
     
    436436   ...     from fipy.viewers import make 
    437437   ...     distanceViewer = make(distanceVar, limits = { 'datamin' :-1e-9 , 'datamax' : 1e-9 }) 
    438    ...     acceleratorViewer = make(acceleratorVar.getInterfaceVar()) 
     438   ...     catalystViewer = make(catalystVar.getInterfaceVar()) 
    439439 
    440440The `levelSetUpdateFrequency` defines how often to call the 
     
    458458   >>> for step in range(numberOfSteps): 
    459459   ... 
    460    ...     if __name__ == '__main__': 
    461    ...         if step % levelSetUpdateFrequency == 0: 
    462    ...             distanceVar.calcDistanceFunction() 
     460   ...     if step % levelSetUpdateFrequency == 0: 
     461   ...         distanceVar.calcDistanceFunction() 
    463462   ... 
    464    ...         extensionVelocityVariable.setValue(depositionRateVariable()) 
     463   ...     extensionVelocityVariable.setValue(depositionRateVariable()) 
    465464   ... 
    466465   ...     distanceVar.updateOld() 
    467    ...     acceleratorVar.updateOld() 
     466   ...     catalystVar.updateOld() 
    468467   ...     metalVar.updateOld() 
    469    ...     bulkAcceleratorVar.updateOld() 
     468   ...     bulkCatalystVar.updateOld() 
    470469   ...     distanceVar.extendVariable(extensionVelocityVariable) 
    471    ...     if __name__ == '__main__': 
    472    ...         dt = cflNumber * cellSize / max(extensionVelocityVariable) 
    473    ...     else: 
    474    ...         dt = 0.1 
     470   ...     dt = cflNumber * cellSize / max(extensionVelocityVariable) 
    475471   ...     advectionEquation.solve(distanceVar, dt = dt)  
    476    ...     surfactantEquation.solve(acceleratorVar, dt = dt) 
     472   ...     surfactantEquation.solve(catalystVar, dt = dt) 
    477473   ...     metalEquation.solve(metalVar, dt = dt,  
    478474   ...                         boundaryConditions = metalEquationBCs) 
    479    ...     bulkAcceleratorEquation.solve(bulkAcceleratorVar, dt = dt, 
    480    ...                                   boundaryConditions = acceleratorBCs) 
     475   ...     bulkCatalystEquation.solve(bulkCatalystVar, dt = dt, 
     476   ...                                   boundaryConditions = catalystBCs) 
    481477   ... 
    482478   ...     if __name__ == '__main__': 
    483479   ...         distanceViewer.plot() 
    484    ...         acceleratorViewer.plot() 
     480   ...         catalystViewer.plot() 
    485481  
    486482   >>> if __name__ == '__main__': 
     
    492488 
    493489   >>> import os 
    494    >>> testFile = 'test.gz' 
    495490   >>> import examples.levelSet.electroChem 
    496    >>> import gzip 
    497491   >>> filepath = os.path.join(examples.levelSet.electroChem.__path__[0],  
    498    ...                         testFile) 
    499    >>> filestream = gzip.open(filepath,'r') 
    500    >>> import cPickle 
    501    >>> testData = cPickle.load(filestream) 
    502    >>> filestream.close() 
    503    >>> print acceleratorVar.allclose(testData) 
     492   ...                         'test.gz') 
     493 
     494   >>> from fipy.tools import dump 
     495   >>> print catalystVar.allclose(dump.read(filepath)) 
    504496   1 
    505497