ohno / Antique.jl

Self-contained, well-tested, well-documented Analytical Solutions of Quantum Mechanical Equations.
https://ohno.github.io/Antique.jl/
MIT License
19 stars 3 forks source link

Add DomainError #44

Closed ohno closed 3 months ago

ohno commented 5 months ago

Add domain checks to all models. ~However, all functions must accept objects of Symbolics.jl as arguments.~ Please determine whether the argument is a real number before domain check. Quantum numbers may be considered as integers.

ohno commented 4 months ago

for 3D models:

if r<0
  throw(DomainError(r, "r=$r is out of the domain (0≦r)"))
end
ohno commented 4 months ago

for quantum numbers:

if 0 <= n
  error("Error: n must be non-negative")
end
ajarifi commented 4 months ago

Is the domain check only for range r or other parameters such as m, hbar, L, alpha, etc which should be positive? Also, I checked the code. There are two versions.

function inputchk(model::PoschlTeller,λ,n,n_max)
  if (λ ≈ round(λ)) == false
    @show(λ,round(λ),λ ≈ round(λ))
    error("Error: Currently only integer values for λ are supported.")
  end

  if (n ≈ round(n)) == false
    @show(n,round(n),n ≈ round(n))
    error("Error: n is the index of the n-th excited state. It must be an integer.")
  end

  if n < 0 || n > n_max
    @show(n,n_max)
    error("Error: n must be non-negative and smaller than n_max: 0 <= n <= n_max")
  end
end

or

if r<0
  throw(DomainError(r, "r=$r is out of the domain (0≦r)"))
end

If it is only range r, I think Ohno-san already put this domain check for spherical harmonics and rigid rotor.

ohno commented 4 months ago

It is too hard to check all optional variables. I will only check the main arguments ($x$ or $r$, $\theta$, $\varphi$).

ohno commented 4 months ago

The progress is as follows:

lhapp27 commented 4 months ago

I had already added the error checks for PoschlTeller and InfinitePotentialWell3D in the past, see PullRequest #58 .

ohno commented 4 months ago

@lhapp27 I almost completed this issue. There was just a small English problem. I'm not sure what "smaller than nmax" means. $n < n\mathrm{max}$ or $n \leq n_\mathrm{max}$? I chose "This function is defined for 0 ≤ n ≤ n_max.".

ohno commented 3 months ago

@ajarifi This is just a note of our discussion. The quantum numbers of the spherical oscillator are as follows:

N=2n+l n l
0 0 0
1 0 1
2 1 0
2 0 2
3 1 1
3 0 3
4 2 0
4 1 2
4 0 4
5 2 1
5 1 3
5 0 5
6 3 0
6 2 2
6 1 4
6 0 6
lhapp27 commented 3 months ago

@lhapp27 I almost completed this issue. There was just a small English problem. I'm not sure what "smaller than n_max" means. n<nmax or n≤nmax? I chose "This function is defined for 0 ≤ n ≤ n_max.".

Is that a general question, or do you refer to the PoschlTeller potential? In general I'd say that "smaller than" means "<", and "smaller or equal" means "<=". I checked the PoschlTeller documentation and found that there is some inconsistency between the maximum number of bound states and the highest quantum number. I thought I had fixed that in a previous version, but maybe not properly. I will check it again, but maybe not before the weekend.

ohno commented 3 months ago

Thank you for your reply. I meant both. Okay, I will open a new issue regarding the fix for the maximum number of bound states and the highest quantum number.

ohno commented 3 months ago

I think this issue is almost completed. The remainings will be completed via this pull request https://github.com/ohno/Antique.jl/pull/63.