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

A minor issue on ACE.SphericalHarmonics:cart2spher #137

Open
zhanglw0521 opened this issue Jun 12, 2022 · 0 comments
Open

A minor issue on ACE.SphericalHarmonics:cart2spher #137

zhanglw0521 opened this issue Jun 12, 2022 · 0 comments

Comments

@zhanglw0521
Copy link
Collaborator

If the input of cart2spher is $(0,0,0)$ under Cartesian, it returns NaN for the field $\cos\theta$, which leads to a state that cannot be recognised by function evaluate. Can we map Cartesian $(0,0,0)$ to something like $(0,1,0,1,0)$ under the spherical coordinate system (though we can choose both angles freely...).

e.g., change it to

function cart2spher(R::AbstractVector)
	@assert length(R) == 3
	r = norm(R)
	if r == 0
		return SphericalCoords(0.0, 1.0, 0.0, 1.0, 0.0)
	end
	φ = atan(R[2], R[1])
	sinφ, cosφ = sincos(φ)
	cosθ = R[3] / r
	sinθ = sqrt(R[1]^2+R[2]^2) / r
	return SphericalCoords(r, cosφ, sinφ, cosθ, sinθ)
end
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

No branches or pull requests

1 participant