Closed dmargarone closed 2 years ago
dear @dmargarone
the question concerns rather python than FBPIC itself.
The code accepts any function dens_func
that can be 2D in (z,r)
space or 3D in a full Cartesian space (x,y,z)
.
In a simplest case, if you have 1D longitudinal profile, i.e. some array z_coord
in microns and corresponding density n_p
normalized to 1 (measured or from CFD simulation), you may define it with something like this:
dens_func = lambda z, r : np.interp(z, z_coord, n_p, left=0, right=0)
For 3D profiles, depending on your data, you may either consider combinations of 1D interpolators (like np.interp
above), or a full 3D interpolator of you taste (see scipy.interpolate for more options)
Thank you so much @hightower8083 for answering this question.
Exactly as you mentioned, I have 1D longitudinal profile (data of 2 columns ). 1st column z-coordinate and 2nd column plasma density.
Sorry, but I have one query here ....
(1) why you wrote "lambda" in the dens_func ?
Thank you so so much. DM
lambda
is a standard inline function definition in python, but if you are not familiar with it you may prefer to use a more common way:
import numpy as np
def dens_func(z, r):
value = np.interp(z, z_coord, n_p, left=0, right=0)
return value
or even better consider a scipy method (avoids reinititalization at each call, but make sure there's no NaN
values in the input arrays)
from scipy.interpolate import interp1d
dens_func_interp = interp1d(z_coord, n_p, bounds_error=False, fill_value=0.0)
def dens_func(z, r):
value = dens_func_interp(z)
return value
Thank you Thank you Thank you @hightower8083
You are great teacher. You realized correctly that I am not good in Python. Actually, I started Python only after becoming a user of FBPIC. Basically, I am a C and Matlab user. Nowadays, I am trying to learn Python in parallel to FBPIC.
You all guys are so wonderful and kind that I have no words to praise you .... simply great !!
Thank you for helping on this issue. It is now really clear.
Lovingly, DM
Hi guys !!
Like external electron beam or field, is it possible to read the plasma density profile from file ?
For example, I have a density profile measured experimentally, I could fit this profile and make a similar density profile numerically. However, if we can read the experimentally measured profile directly in to the code it may be more realistic and accurate.
Thanks in advance. DM