How can I plot the Voigt Profile function with varying values of a in Python?

  • Thread starter sketos
  • Start date
  • Tags
    Python
In summary, the key to solving this problem is to use numerical integration to calculate the integrals.
  • #1
sketos
56
0
I very new to python and this might look relatively easy to some of you. I need to write a code so that

[tex] H(a,u) = \frac{a}{\pi} \int_{-\infty}^{\infty} \frac{e^{-y^2}}{a^2+(u-y)^2}dy [/tex]

it plots the above function for different values of the a parameter, so that ultimately i will have a graph of 3 or more function of the form [itex]H(a_1,u)[/itex], [itex]H(a_2,u)[/itex], [itex]H(a_3,u)[/itex] as functions of u. Can anyone provide a code ?
 
Technology news on Phys.org
  • #2
sketos said:
I very new to python and this might look relatively easy to some of you. I need to write a code so that

[tex] H(a,u) = \frac{a}{\pi} \int_{-\infty}^{\infty} \frac{e^{-y^2}}{a^2+(u-y)^2}dy [/tex]

it plots the above function for different values of the a parameter, so that ultimately i will have a graph of 3 or more function of the form [itex]H(a_1,u)[/itex], [itex]H(a_2,u)[/itex], [itex]H(a_3,u)[/itex] as functions of u. Can anyone provide a code ?

The key is
sketos said:
I need to write a code
We're not going to do this for you. We'll be happy to help you out on it, but you need to show us what you've tried.
 
  • #3
import numpy as np
import pylab as pl
from math import exp
from scipy.integrate import quad

def voigt( u , a ):

def integrand( y ):

return exp(-y**2)/( a**2 + ( u - y )**2 )

return quad( integrand ,-np.inf , np.inf )x = np.linspace(-100 , 100 )

Func = voigt( x , 0.1 )

pl.plot( x , Func )

pl.show()

This is as far as i got before i posted...
 
  • #4
sketos said:
I very new to python and this might look relatively easy to some of you. I need to write a code so that

[tex] H(a,u) = \frac{a}{\pi} \int_{-\infty}^{\infty} \frac{e^{-y^2}}{a^2+(u-y)^2}dy [/tex]

it plots the above function for different values of the a parameter, so that ultimately i will have a graph of 3 or more function of the form [itex]H(a_1,u)[/itex], [itex]H(a_2,u)[/itex], [itex]H(a_3,u)[/itex] as functions of u. Can anyone provide a code ?

Teach a man to fish he eats for a lifetime. Here's some important tools to breaking it down. I suck at calculus so I use this to calculate integrals.
http://integrals.wolfram.com/index.jsp
You would enter it in the Wolfram language, where x^y means x to the power of y, remember your parenthesis. Then take the output, and code it in the python language...its the same except x**y = x to the power of y.
 

1. What is the Voigt Profile?

The Voigt Profile is a mathematical function used to describe the line shape of spectral lines in various fields of science, such as astronomy and spectroscopy. It is a convolution of the Gaussian and Lorentzian functions, and takes into account both the Doppler broadening and natural broadening of spectral lines.

2. How is the Voigt Profile related to Python?

Python is a popular programming language used in scientific research and data analysis. The Voigt Profile can be implemented in Python through various libraries and packages, making it a useful tool for researchers and scientists working with spectral data.

3. What are the advantages of using Python for the Voigt Profile?

Python offers a wide range of libraries and packages specifically designed for scientific computing and data analysis. It also has a user-friendly syntax, making it easier for scientists to implement and customize the Voigt Profile according to their specific needs. Additionally, Python is an open-source language, meaning it is constantly being updated and improved by a large community of developers.

4. Are there any limitations to using Python for the Voigt Profile?

One potential limitation of using Python for the Voigt Profile is the speed of computation. While Python is generally a fast language, it may not be as efficient as other programming languages when dealing with large datasets or complex calculations. However, there are ways to optimize and improve the performance of Python code for the Voigt Profile, such as using vectorization and parallel processing.

5. Can the Voigt Profile be used for all types of spectral data?

The Voigt Profile is a versatile function that can be applied to a wide range of spectral data, including absorption, emission, and fluorescence spectra. However, it may not accurately describe the line shape for all types of spectra, particularly those with very broad or asymmetric lines. In these cases, other line shape functions may be more appropriate.

Similar threads

  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
Replies
2
Views
895
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
2
Replies
50
Views
4K
  • Programming and Computer Science
Replies
2
Views
1K
  • Programming and Computer Science
Replies
7
Views
3K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
1
Views
671
  • Programming and Computer Science
Replies
4
Views
4K
Back
Top