scienza / schroedinger Goto Github PK
View Code? Open in Web Editor NEWA Schroedinger Equation solver in C++, with flexible basis definition
License: GNU Lesser General Public License v2.1
A Schroedinger Equation solver in C++, with flexible basis definition
License: GNU Lesser General Public License v2.1
Change the CMakeLists in order to compile:
Implement the solver class:
interface
method: keep the option open to use more solversRequisites to consider:
We should use a proper library (I propose https://github.com/gabime/spdlog ) to manage logs. Have a look
at it, there are examples of how to use it and it's explained its flexibility.
This have to be included as an external module (as we did with googletest module), also modifying the main CMakeLists.txt in order to compile it.
Implement boundary condition property, to be used in Numerov
. I believe the best place to set the property is basis
, while the setup in Numerov
should be done when calling the Numerov::Solve
method.
This initialisation (of Numerov
wf[0]=0.; wf[1] = 0.1;
ndR) does not belong to the start of class, but to something that should be called beforefindWavefunction
. That is, the setup of the boundary conditions, that should be insolve
andbisection
.
Now bisection is too coupled with solved, so it cannot be generalized, so there is fine. (cf. later comment)
Originally posted by @AndreaIdini in https://github.com/Scienza/Schroedinger/diffs
Construct a trapezoidal numerical integration routine that generalizes to integrals in many dimensions.
Just shut up already!
Given an ASCII file for potential, e.g.,
0.0 2.1
0.2 2.2
0.4 2.7
...
20.0 0.01
reads the potential and the basis mesh (implying either 1D or radial, for example)
Getter should be made const
according to @GabrielePisciotta
Be careful about memory management in methods and fix with known recipes.
In file Numerov.cpp
function operator<<
, modify format of printing wavefunction (in the future this will belong to class States
).
Modify the priting format, to include coordinate (from basis). Also to be done for Potential
class printing.
prefer spaces to tabs for ASCII compatibility.
Way better to print all together
x (from the basis) waveFunction Probability
0.000000 1.234e-10 2.012e-20
0.100000 ...
...
Could be made into a easy issue for @Bhez
Originally posted by @AndreaIdini in https://github.com/Scienza/Schroedinger/diffs
The multidimensional test for harmonic oscillator does not work. The state
has the correct energy, but the wave function
keeps its 0s initialisation.
The code is an exact copy of the code in main.cpp
that prints the wave function with good results! Might be a mishandling of pointers?
TODO: once fixed the wave function output, I will do multidimensional tests on Finite Well potential, and maybe higher eigenvalues options.
Right now tests are don by absolute differences with the analytic wave function. The threshold is eyeballed.
Find something more clear and meaningful.
One possible Numerov precision limited when treating discontinuous potentials.
Implement CMake and/or installer to compile the program and gtest.
Verify compiler version/compatibility and eventual additional libraries.
Come mi unisco?
Thread to evaluate possible pro-cons of Graphical Libraries that can be used in the project. Feel free to edit this message and comment.
Cf. wikipedia List
Make a working example of interactive custom_workflow()
in main.cpp
Originally posted by @AndreaIdini in https://github.com/Scienza/Schroedinger/diffs
In the last commit before this issue, there is a stub for a public class (also commutable to structure) initializer.
The idea behind this is to get an intuitive and versatile initialisation of basis states.
It is related to problems throughout the last instance of the code #33 #30 #22 #8
The problem is that the state can be initialized in several different ways, and operator overload is boring, complicated and sometimes not straightforward to implement. E.g. we want to implement as continuous basis as int unsigned nbox; double mesh
, or double start, end; int nbox
and also double start, end, mesh;
.
A way to solve this is to overload operators.
But, when we want to initialise a spherical basis, other than one continuous r coordinate we need also quantized angular momentum quantum numbers. Therefore we can implement a spherical basis (l coupling) providing only maximum l either with 1 double and 2 int, or 2 double and 2 int, or 3 double and 1 int. But what if we want to provide min and max l? how could you overload? there are several possible overload combinations, and
buildSpherical3D(...)
buildCartesian1D(...)
pro - easy and straightforward to implement.
cons - tedious implementation; many methods that can confuse user.
Implement in [this commit]
(230a020)
Base
class and DiscreteBase
pro - versatile, agile, amazing, computersciency... etc...
cons- as it is doesn't really fit the story
initializer
pro - easy
cons- ?
Ideally we want the user (and us) to build factorized basis with ease. In pseudocode we could think to build a 3D spherical, j-coupled or ls-coupled basis, just like this in pseudocode:
Mesh = 0.1
Nbox = 1000
Lmax = 20
spin = 1/2
build(SphericalJ)
Or a 3D Cartesian
Mesh = 0.1
Nbox = 1000
build(Cartesian, 3)
Or directly providing the vector for cartesian
std::vec<double> x
build(Cartesian, 1)
or otherwise basis
std::vec<double> x
Lmax = 20
spin = 1/2
build(SphericalJ)
Basis::ContinuousBasis . coord
cannot be tested as vector but only if considered elements of a vector.
This from implementation of Base test: 17795e4
At the moment, the program gets only one state composed of
It is needed to introduce a system to find a mange all the states in a given range.
For some problem it is convenient to work in momentum space, and be able to go back and forth from it to the real space.
Implement a routine that does the latter.
Once the States
class has been implemented in issue #47 this is an easy enhancement.
@mechanapoleon this
Find Energy
routine can be easily modified to find all the eigenstates betweene_min
ande_max
.
At the moment, it is a simple scan of the zero starting frome_min
with meshe_step
. Once a change of sign has been found, it starts a bisection to find the correct Energy and break from loop.
Once the class
States
able to manage different states is introduced, it is easy to modify this routine to notbreak
when the solution is found but to save the solution and continue scanning.
To be made issue
Originally posted by @AndreaIdini in https://github.com/Scienza/Schroedinger/diffs
The base class is arguably the most critical part of the program.
A detailed description of a proposed implementation is available in the wiki
generalize the implementation of different dimensions in basis class
The automatic testing is now implemented using Google Tools. As it is in 23/01/18 it does not work as intended.
Make it work comparing analytical wavefunction and numerov solution point-by-point (eventually).
Compare Eigenvalues too.
setting err = 1e-10
the box wave function tests ok.
However, setting a lower error threshold implies false test. The numerov solution output is up to 10^-11 precise, but setting a lower precision does not put it in infinite loop. Probably the limit on bisection blocks the infinite loop, and the 0.1 mesh implies the limit on precision.
To be verified.
Schroedinger Equation in the finite potential well off by factor 2 on the height of the potential. Eigenenergy to be checked.
circleci shield does not update with circleci status
Continuous basis can be real, but also complex (cf. Berggren basis).
Implement a creation that takes into account complex basis.
Maybe through template
objects.
Question 1:
Numerov::Numerov(Potential potential, int nbox) : Solver(potential, nbox)
Al momento inizializza la wavefunction, che in realta' andrebbe inizializzata quando si lancia l'algoritmo di bisezione.
Dato che numerov quello che fa e' lanciare la bisezione una volta, va bene anche cosi' istanziarlo col costruttore, pero' se si cancella quella parte e si fa un init vuoto va tutto in vacca anche inizializzando dentro la bisezione... perche'?
Question 1.5:
wave function should be initialised in Solver
, because the initialisation is valid for every type of solver. It could be more convenient to initialise it directly in the routine that does the actual solving to avoid propagating errors in asymmetric solvers. E.g. wave function(border) = 0
, 10^-5 is recognised as solution at first matching with 0; 10^-4 at second iteration matching with 10^-5; 10^-3 matching with 10^-4...etc... Evaluate what's best practice.
Question 2:
Numerov::Numerov(Potential potential, int nbox)
takes Potential
as input. But potential
is already a member of class Solver
. Is there a reason for it?
Question 3:
Can we make more clear or efficient the current implementation of scanning + bisection?
At the moment the solver start scanning from the lowest energy with a certain step, once found conditions for sign changes looks at the bisection solution in the middle of the last step.
Applicate principles discussed here
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.