Calculating molarity, weight concentration from absorbance value for plasmonic nanoparticles in solution

It is common to measure the peak absorbance of the plasmonic nanoparticles in solution and then get the following:  Molarity (moles/liter) Number of particles per ml  Weight concentration (ug/ml) I wrote a small python function to extract these parameters.  The following inputs are needed for the function d_nm :   diameter of the particle in nanoparticle od :  peak OD measured from the absorbance plot path_length_cm :  cuvette length in centimeter density_g_per_cm3 :  for gold it is 19.28, for silver it is 10.49 molar_Extinction_perM_percm :  Molar extinction coefficient extracted from https://www.sigmaaldrich.com/technical-documents/articles/materials-science/nanomaterials/gold-nanoparticles.html This can extracted from measuring absorbance at different concentrations and then Read More …

Creating Energy Band Diagrams for Solar cells and LED

Energy band diagrams are used to visulize the electron and hole transport in Solar cells and LED. I want to quickly draw them and came up with a python module. You can download the module at my github repository. Here’s an example on how to use this code. from Band_diagram import metal, semiconductor, plot # # Define the metals and semiconductors. Here wf is the work function of metals, cb is conduction band minimum and vb is valance band maximum wrt to vacuum level ITO = metal(wf = -5.2, name= ‘ITO’) p_nio = semiconductor(cb = -1.85, vb = -5.49, name Read More …

Tab autocompletetion with python interpreter in bash terminal

I want to tab autocomplete commands in my python interpreter within bash terminal. This is very useful when I import a module and just want to browse through the methods and autocomplete. Found two ways to do it. Thanks to stack overflow posts. Method 1 (as mentioned here): This is easy. Install pyreadline (pip install pyreadline) and use ipython. This is a snapshot of it working. Method 2 ( as mentioned here): This is for standard  python interpreter in bash terminal (such as in Ubuntu). This method requires readline and rlcompeter modules. Install these modules if you do not have Read More …

Did I turn off the stove…ESP8266

My wife and I leave the house after a good meal and after like 20 minutes in the car, I ask my wife…did we turn off the stove? My wife answers…you were the last one to cook. What to do now? Go back home and check it. Now, that sucks. To solve this common problem, I came up with a solution to use internet of things (IOT) to monitor stove status. So here is a final product, a URL I type in my browser and I can see the stove status.   How to do IOT cheaply? use ESP8266 module. Read More …

Coupled Dipole Approximation in Python

Coupled dipole approximation (CDA) method is a numerical method to calculate the optical properties (scattering and absorption) of interacting dipoles. This method is used in discrete dipole approximation method (like in DDSCAT software), where a big particle (also known as target) is broken into lot of interacting dipoles arranged in cubic lattice. CDA can also be used to calculate the optical properties (scattering and absorption) of random particle distributions (like in L. Zhao et al. J. Phys. Chem. B,  107,  30, 7343,2003 ) and assuming each particle to be small enough that it behaves like a dipole. I have implement Read More …

Fitting Complex Metal Dielectric Functions with Differential Evolution Method

The real and imaginary part of dielectric permittivity of the metals is important to simulate the optical properties of metal films and nanoparticles. Permittivity data is obtained experimentally by ellipsometry and is fitted with analytical models. The most common model for fitting experimental data is with Drude-Lorentz model shown below. $$\epsilon(\omega)=1-\frac{f_1\omega_p^2}{(\omega^2+i\Gamma_1\omega)}+\sum_{j=2}^{n}\frac{f_j\omega_p^2}{(\omega_{o,j}^2-\omega^2-i\Gamma_j\omega)}$$ The first term is the Drude part. It represents the response of electron in the Fermi sea/conduction band when it sees external oscillating electric field (these transitions are called as intraband transitions). The Drude term has the plasma frequency ($\omega_p$, oscillator strengh ($f_1$) and damping term ($\Gamma_1$). The rest Read More …

Dealing with plotting negative, zero and positive values in log scale

Sometimes you have to show positive, zero and negative number in log scale. However you cannot take log of negative numbers and zero. But one could approximate it with a log transform modulus as stated here. In Python with numpy: from numpy import sign, abs, log10 import matplotlib.pyplot as plt # Data varies in several magnitudes and has both positive, zero and negative numbers x = [-10000,-1000,-100,-10,0,10,100,1000,10000] # log modulus transform x_log_modulus_transform= sign(x)*(log10(abs(x)+1)) f, ax = plt.subplots(2, sharex=True) ax[0].plot(x,’o’) ax[0].margins(x=0.12, y=0.2) # for better visualization of datapoints at the end of axis ax[1].plot(x_log_modulus_transform,’o’) ax[1].margins(x=0.12, y=0.2) # for better visualization of Read More …

Python code for generating plasmonic metal dielectric functions

I keep needing a python code to generate the dielectric functions of plasmonic materials such as Au, Ag, Pd, and Pt. I wanted the dielectric functions called by other python codes such as TMM. So I wrote a python version of LD.m LD.m is a matlab file written by Bora Ung that produces dielectric functions of metals either for Lortenz and Loretnz drude models. The dielectric functions are given as follows: . The first part of the function is the Drude part and the second part is the Lorentz part. The parameters for these models are taken from Rakic et Read More …

DDSCAT on amazon EC2

Amazon provides high performance computing capabilities through their EC2 service. You can find more information here They provide a 750 hr free instance with their a free-tier program. If you want more resources, you can pay for it. See the pricing, pricing seem very reasonable. I wanted to see how easy it was to install ddscat and run some examples files. Amazon allows to create an instance through their very easy-to-use web interface. I chose to install ubuntu amazon machine image on the instance.  While you are creating an instance you are allowed to create a key pair file and download Read More …

Plasmonic Materials in MEEP > 1.2

Here is how I was implementing plasmonic materials in meep1.1 scheme code. Unlike Meep 1. 1, Meep >= 1. 2 changed the way materials are defined. Here I will describe how to change the material definition code from meep1.1 to meep 1.2 . Please note that one can still use the material definition written from Meep <1.2 for Meep >=1.2 but not vice versa. Installation of Meep 1.2 on ubuntu You can follow instructions given in my previous post to compile Meep 1.2 from the source code, but the procedure is outdated and one can use the recently pre-compiled meep Read More …