<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Transient simulation of organic light emitting electrochemical cell
This is sample simulation of electrochemical doping in light-emitting electrochemical cell, visualizing the effect of assumed electronic mobility model.
Step1:  Model and parameters
Step2:  Results
In the plots below, electrons are shown in red, and holes are shown in blue.
Concentration independent mobility
Step3:  Concentration dependent mobility
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
from matplotlib import colors
import matplotlib.pylab as plt
from oedes.fvm import mesh1d
from oedes import context,init_notebook,testing,models
import numpy as np
from oedes.functions import Aux2
init_notebook()
Explanation: Transient simulation of organic light emitting electrochemical cell
This is sample simulation of electrochemical doping in light-emitting electrochemical cell, visualizing the effect of assumed electronic mobility model.
End of explanation
class CustomMobility(models.MobilityModel):
    def mu_func(self, T, E, c):
        mu0 = 5e-11
        mu1 = 5e-9
        W = 0.04
        f0 = 0.3
        f = c / 0.3e27
        return (mu1 - mu0) * Aux2((f0 - f) / W) + mu0
        
    def mobility(self, parent, ctx, eq):
        mu_cell = self.mu_func(ctx.varsOf(eq.thermal)['T'], ctx.varsOf(eq.poisson)['Ecellm'], ctx.varsOf(eq)['c'])
        mu_face = eq.mesh.faceaverage(mu_cell)
        ctx.varsOf(eq).update(mu_face = mu_face, mu_cell = mu_cell)
mesh = mesh1d(2e-6)
def solve(mu_ions, mobility_model, additional_params=None, voltage=5.):
    model = models.BaseModel()
    models.std.electronic_device(model, mesh, 'pn', mobility_model = mobility_model)
    cation, anion, initial_salt = models.std.add_ions(model, mesh, zc=1, za=-1)
    model.setUp()
    xinit = initial_salt(0.1e27)
    params = {'T': 300.,
              'electron.energy': 0.,
              'electron.N0': 0.3e27,
              'hole.energy': -2.,
              'hole.N0': 0.3e27,
              'electrode0.workfunction': 2.,
              'electrode1.workfunction': 0.,
              'electrode0.voltage': voltage,
              'electrode1.voltage': 0,
              'cation.mu': mu_ions,
              'anion.mu': mu_ions,
              'npi': 0,
              'epsilon_r': 3.
              }
    if additional_params is not None:
        params.update(additional_params)
    c = context(model,x=xinit)
    c.transient(params, 1, 1e-9)
    return c
def transientplot(data):
    N0 = 5e27
    n = 20
    for it, t in enumerate(10**np.linspace(-5, -1, n + 1)):
        out = data.attime(t).output()
        c = 1 - (1. - it / n)
        ncolor = colors.rgb2hex((1,1 - c,1 - c))
        pcolor = colors.rgb2hex((1 - c,1 - c,1))
        plt.plot(mesh.cells['center'] * 1e9,out['electron.c'] / N0,ncolor)
        plt.plot(mesh.cells['center'] * 1e9,out['hole.c'] / N0,pcolor)
        testing.store(out['electron.c'], rtol=1e-7, atol=1e-3 * N0)
        testing.store(out['hole.c'], rtol=1e-7, atol=1e-3 * N0)
    plt.yscale('log')
    plt.ylim([1e-5, 1.])
    plt.xlabel('$x$ [nm]')
    plt.ylabel('$c/N_0$')
Explanation: Model and parameters
End of explanation
mu_params = {'electron.mu':5e-11,'hole.mu':5e-11}
c=solve(5e-11, models.MobilityFromParams(), mu_params)
transientplot(c)
Explanation: Results
In the plots below, electrons are shown in red, and holes are shown in blue.
Concentration independent mobility
End of explanation
c=solve(mu_ions=5e-11, mobility_model=CustomMobility())
transientplot(c)
Explanation: Concentration dependent mobility
End of explanation
<END_TASK>