From cf8e7a885fe0e8cf698b0c1e8de0ab5658061b39 Mon Sep 17 00:00:00 2001 From: Kit McColl Date: Thu, 25 Jun 2020 14:27:21 +0100 Subject: [PATCH 1/2] Redefined the necessary functions Left the notebook the same, since it will now be correct with the way the functions are defined. --- examples/lattice_mc_examples.ipynb | 2 +- lattice_mc/simulation.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/lattice_mc_examples.ipynb b/examples/lattice_mc_examples.ipynb index b73f4c4..cc69edb 100644 --- a/examples/lattice_mc_examples.ipynb +++ b/examples/lattice_mc_examples.ipynb @@ -951,7 +951,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.1" + "version": "3.7.4" } }, "nbformat": 4, diff --git a/lattice_mc/simulation.py b/lattice_mc/simulation.py index ea3ed33..c2dcc1d 100644 --- a/lattice_mc/simulation.py +++ b/lattice_mc/simulation.py @@ -271,15 +271,15 @@ def collective_correlation( self ): return None @property - def collective_diffusion_coefficient( self ): + def reduced_ionic_conductivity( self ): """ - Returns the collective or "jump" diffusion coefficient, D_J. + Returns the reduced ionic conductivity, \u03C3\' ( D_J * n_natoms). Args: None Returns: - (Float): The collective diffusion coefficient, D_J. + (Float): The reduced ionic conductivity, \u03C3\' ( D_J * n_natoms). """ if self.has_run: return self.atoms.collective_dr_squared() / ( 6.0 * self.lattice.time ) @@ -287,18 +287,18 @@ def collective_diffusion_coefficient( self ): return None @property - def collective_diffusion_coefficient_per_atom( self ): + def collective_diffusion_coefficient( self ): """ - The collective diffusion coefficient per atom. D_J / n_atoms. + Returns the collective or "jump" diffusion coefficient, D_J. Args: None Returns: - (Float): The collective diffusion coefficient per atom, D_J / n_atoms. + (Float): The collective diffusion coefficient, D_J. """ if self.has_run: - return self.collective_diffusion_coefficient / float( self.number_of_atoms ) + return self.reduced_ionic_conductivity / float( self.number_of_atoms ) else: return None From 37ff69fb30182fa40bf36b4e1cd367698f5181dc Mon Sep 17 00:00:00 2001 From: Kit McColl Date: Wed, 8 Jul 2020 10:34:33 +0100 Subject: [PATCH 2/2] Fixed error in docstrings for collective_diffusion_coefficient Fixed error in docstrings, updated example jupyter notebook and defined a reduced_ionic_conductivity function. --- examples/lattice_mc_examples.ipynb | 18 ++++++------------ lattice_mc/simulation.py | 30 +++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/examples/lattice_mc_examples.ipynb b/examples/lattice_mc_examples.ipynb index cc69edb..397c645 100644 --- a/examples/lattice_mc_examples.ipynb +++ b/examples/lattice_mc_examples.ipynb @@ -25,9 +25,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "import lattice_mc\n", @@ -45,9 +43,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "# Global variables controlling simulation parallelisation and convergence.\n", @@ -64,9 +60,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "# define temperature scale\n", @@ -131,7 +125,7 @@ "| correlation factor | $f$ | `Simulation.tracer_correlation` | \n", "| collective correlation factor | $f_\\mathrm{I}$ | `Simulation.collective_correlation` |\n", "| tracer diffusion coefficient | $D^*$ | `Simulation.tracer_diffusion_coefficient` |\n", - "| “jump” diffusion coefficient | $D_\\mathrm{J}$ | `Simulation.collective_diffusion_coefficient` |\n", + "| “jump” diffusion coefficient | $D_\\mathrm{J}$ | `Simulation.collective_diffusion_coefficient_per_atom` |\n", "| average site occupations | occ($\\alpha$) | `Simulation.average_site_occupations` |" ] }, @@ -157,7 +151,7 @@ "print( \"f = {}\".format( s.tracer_correlation ) )\n", "print( \"f_I = {}\".format( s.collective_correlation ) )\n", "print( \"D* = {:.3e}\".format( s.tracer_diffusion_coefficient ) )\n", - "print( \"D_J = {:.3e}\".format( s.collective_diffusion_coefficient ) )\n", + "print( \"D_J = {:.3e}\".format( s.collective_diffusion_coefficient_per_atom ) )\n", "# Simulation.average_site_occupations returns a dictionary\n", "for k, v in s.average_site_occupations.items():\n", " print( \"occ({}) = {:f}\".format( k, v ) )" @@ -184,7 +178,7 @@ "source": [ "def simulation_wrapper(_):\n", " s = run_simulation()\n", - " return s.tracer_correlation, s.collective_correlation, s.tracer_diffusion_coefficient, s.collective_diffusion_coefficient" + " return s.tracer_correlation, s.collective_correlation, s.tracer_diffusion_coefficient, s.collective_diffusion_coefficient_per_atom" ] }, { diff --git a/lattice_mc/simulation.py b/lattice_mc/simulation.py index c2dcc1d..af3dc2a 100644 --- a/lattice_mc/simulation.py +++ b/lattice_mc/simulation.py @@ -271,15 +271,17 @@ def collective_correlation( self ): return None @property - def reduced_ionic_conductivity( self ): + def collective_diffusion_coefficient( self ): """ - Returns the reduced ionic conductivity, \u03C3\' ( D_J * n_natoms). + Returns the collective or "jump" diffusion coefficient multiplied by the number of atoms, + ( D_J * number_of_atoms). Args: None Returns: - (Float): The reduced ionic conductivity, \u03C3\' ( D_J * n_natoms). + (Float): the collective or "jump" diffusion coefficient multiplied by the number of + atoms, ( D_J * number_of_atoms). """ if self.has_run: return self.atoms.collective_dr_squared() / ( 6.0 * self.lattice.time ) @@ -287,7 +289,7 @@ def reduced_ionic_conductivity( self ): return None @property - def collective_diffusion_coefficient( self ): + def collective_diffusion_coefficient_per_atom( self ): """ Returns the collective or "jump" diffusion coefficient, D_J. @@ -298,7 +300,25 @@ def collective_diffusion_coefficient( self ): (Float): The collective diffusion coefficient, D_J. """ if self.has_run: - return self.reduced_ionic_conductivity / float( self.number_of_atoms ) + return self.collective_diffusion_coefficient / float( self.number_of_atoms ) + else: + return None + + @property + def reduced_ionic_conductivity( self ): + """ + Returns the reduced ionic conductivity, \u03C3\' ( D_J * ( number_of_atoms / + number_of_sites ) ). + + Args: + None + + Returns: + (Float): The reduced ionic conductivity, \u03C3\' ( D_J * ( number_of_atoms / + number_of_sites )). + """ + if self.has_run: + return self.atoms.collective_diffusion_coefficient_per_atom * float( self.number_of_atoms / self.number_of_sites ) else: return None