Hi, I simulated a pn junction on Device and get the simulation results for n and p distribution separately. How do I put them together and find the total carrier concentration, and the results for n and p are both the majority carrier concentration, is there any way to let me plot the minority carrier concentration?

# Simulation the carrier concentration for both electrons and holes

**yr1**#1

请问DEVICE如何查看charge的carrier总浓度分布

How to modify the charge density as 2-dimension(x&z cross section) data?

**aalam**#2

Hi. I have used the pn junction diode example in KB to demonstrate my answers.

- The electron and hole concentrations are reported for the entire simulation region. They are not for majority carriers only. For example, in the figure below you can see the electron density in the pn diode for a forward bias voltage of 0.2 V. You can see that in the p-doped region (top) electron density is very small (~1e3 /cm^3) and it is the minority carrier in this region. Also, in the n-doped region, the value is large (~1e15 /cm^3) where it is the majority carrier.

- If you want to add the electron and hole values, you will have to get the electron and hole concentrations from a charge monitor (like the one in the example) and add them. I have copied a script below that takes the n and p results from the “charge” monitor and adds them to get “total” which is the total charge concentration (note I have multiplied with “e” charge of a single electron).

## get the results

charge = getresult(“CHARGE::charge”,“charge”);

n = charge.n;

p = charge.p;

## calculate total charge

total = e*(-n+p);

## get the coordinate information and voltage information

x = charge.x;

y = charge.y;

z = charge.z;

elements = charge.elements;

V_emitter = charge.V_emitter;

## create a new dataset to visualize total charge

total_charge = unstructureddataset(x,y,z,elements);

total_charge.addparameter(“V_emitter”,V_emitter);

total_charge.addattribute(“total”,total);

visualize(total_charge);

To learn more about the (unstructured) dataset visit this page in KB.

**yr1**#3

Awesome! But Im not sure where I put these command to? do I save the data and reopen them in matlab and copy these command below it?

**aalam**#4

No. You can just copy/paste them in the script prompt at the bottom of the user interface (UI)

Or you can copy it to the script editor at the right side of the UI and run it from there.

**yr1**#5

Too stupid…I just sent my file to the support@lumerical.com, the name is MOS3, can you add them to my file?

Thank you very much

**yr1**#6

Alright! I got it. I want to take a more step to show the n distribution at P side, in the file is the region with x less than 0, and p distribution at N side, just for the region with x greater than 0. how do I modify the plot region for each carrier?

**yr1**#7

so the description of my plotting is this:

First, I want to plot the region of x=[-0.3,0.3], z=[3,3.22],y=[-1,1]. this is not same as the simulation region.

Secondly, I want to plot the n distribution, which can be expressed as the ni^2/ P(where ni is the intrinsic carrier concentration and P is the majority carrier at P side) with x=[-0.3,0] and p distribution in x=[0,0.3] which is in N side. both of them are with the y z that I mentioned above.

third thing, make it a 2D plot.

can you give me any advice to revise the code?

**aalam**#8

If you want to plot the charge data for a selected region, the best option probably is to first interpolate the data onto a rectangular grid and then plot it in any region you want. To interpolate the charge data (which is provided on a finite element grid) you can use the interptri command. To learn more about how to use this command, check this page in KB. Once you have the data in a rectangular grid, you can even plot the charge as a line plot easily.