Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tick bug when expanding electric potential to full 2pi #310

Merged
merged 14 commits into from
Sep 20, 2022

Conversation

SebastianRuffert
Copy link
Contributor

This should solve issue #253

@lmh91
Copy link
Collaborator

lmh91 commented Jun 23, 2022

The field calculations seems to work but I can't plot the electric potential and electric field in r-phi:

plot(sim.electric_potential, z= 0) # -> "angles not sorted in ascending order."

Could you please have a look?

@fhagemann
Copy link
Collaborator

Yes, the ticks should be ordered, and ideally, the first tick of a DiscreteAxis should also be the left boundary of the respective interval, i.e.

g = Grid(sim)
g.φ.ticks[1] == g.φ.interval.left

src/ScalarPotentials/ScalarPotential.jl Outdated Show resolved Hide resolved
src/ScalarPotentials/ScalarPotential.jl Outdated Show resolved Hide resolved
@SebastianRuffert SebastianRuffert marked this pull request as draft June 28, 2022 11:06
@SebastianRuffert SebastianRuffert marked this pull request as draft June 28, 2022 11:06
src/ScalarPotentials/ScalarPotential.jl Outdated Show resolved Hide resolved
Comment on lines 55 to 57
P = sortperm(new_ticks)
new_int::Interval{:closed, :open, AT} = Interval{:closed, :open, AT}(new_ticks[P][1], new_ticks[P][end])
new_axφ = DiscreteAxis{AT, :periodic, :periodic}( new_int, new_ticks[P] )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think that this is what we want...

The endpoints of the Interval should not necessarily be the first and last ticks of new_ticks[P], especially when the Interval is :open on the right.

In this function (get_2π_potential), we want to end up with a potential,and in my personal opinion the new_int should also be a -Interval, i.e. where the :closed-:open-Interval ranges from [0,2π[ (or [x,x+2π[ but then again there might be values outside of the [0,2π[ range...)

src/ScalarPotentials/ScalarPotential.jl Outdated Show resolved Hide resolved
- name: "p contact"
id: 1
material: "HPGe"
potential: 4000.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment: p+ contacts usually have a negative potential applied

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

detectors:
- semiconductor:
material: "HPGe"
bulk_type: "p"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bulk_type, at least to my knowledge, should be ignored (?)

@SebastianRuffert SebastianRuffert marked this pull request as ready for review July 14, 2022 06:29
@@ -86,7 +86,7 @@ function get_electric_field_from_potential(epot::ElectricPotential{T, 3, Cylindr
Δp_φ_1 = p[ir ,iφ+1, iz]-p[ir ,iφ, iz]
Δp_φ_2 = p[ir ,iφ, iz]-p[ir ,end, iz]
d_φ_1 = (axφ[iφ+1]-axφ[iφ]) * axr[ir]# to get the proper value in length units
d_φ_2 = (cyclic - axφ[end]) * axr[ir]
d_φ_2 = (cyclic + axφ[iφ] - axφ[end]) * axr[ir]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this?
Right now we always blow up the electric potential to full 2π before calling this function.

So wouldn't axφ[iφ] (iφ = 1 here) be always 0?

@SebastianRuffert SebastianRuffert marked this pull request as draft August 4, 2022 06:46
@fhagemann
Copy link
Collaborator

Why was this closed?

@fhagemann fhagemann reopened this Aug 16, 2022
@fhagemann fhagemann marked this pull request as ready for review August 31, 2022 19:11
@lmh91
Copy link
Collaborator

lmh91 commented Sep 12, 2022

@fhagemann What is the status of this?
It looks good to me. Can this be merged?

@fhagemann
Copy link
Collaborator

I did not yet look into this in detail, might get to this next week. What I see is that we added new config files without corresponding test. It might make sense to add tests for a phi interval not starting at 0 to make sure that everything runs smoothly before merging this into main.

@fhagemann
Copy link
Collaborator

If I have a look at the new config file introduced in this PR (ConeSym), the point types look non-2π-symmetric for some z, e.g.

using SolidStateDetectors, Unitful, Plots
sim = Simulation(SSD_examples[:ConeSym])
calculate_electric_potential!(sim)
plot(sim.point_types, z = 0.009)

image

Not sure exactly what the problem is here (maybe missing important ticks?) but this is something to look into before merging.

@fhagemann
Copy link
Collaborator

fhagemann commented Sep 19, 2022

image

Not sure exactly what the problem is here (maybe missing important ticks?) but this is something to look into before merging.

This happens to be due to rounding errors
(one tick at 0.00575 and one at 0.00625, and the intersection is at either 0.006 or 0.0059999..)

new_ticks_new_zero[2:end] = new_ticks[P]
new_pot_new_zero = Array{eltype(sp.data), 3}(undef, size(sp, 1), l * n + 1, size(sp, 3))
new_pot_new_zero[:,1,:] = (eltype(sp.data) <: AbstractFloat) ? sp[:,1,:] +
(sp[:,end,:] - sp[:,1,:]) * (T(0) - new_ticks_new_zero[2]) / (T(2π) - T(new_ticks_new_zero[end]) * n + T(new_ticks_new_zero[2])) :
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this formula is wrong and it should contain something like Δφ * n rather than T(new_ticks_new_zero[end]) * n.. I will do the calculation and see if this needs to be adjusted.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The permutation of the new potential based on the permutation of the new ticks is missing here, I will push some changes to fix this..

@fhagemann fhagemann dismissed their stale review September 19, 2022 13:04

Changes were incorporated

@fhagemann fhagemann merged commit dda7f0a into JuliaPhysics:main Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expansion of grids to full for cylindrical grids with φmin ≠ 0 is incorrect
3 participants