Skip to content
Snippets Groups Projects
Commit 3d2098a4 authored by Armin Co's avatar Armin Co
Browse files

Updated Gausbox

parent f187f9fb
No related branches found
No related tags found
No related merge requests found
......@@ -177,9 +177,9 @@ void QPong::GameLayer::reset()
const int xRand = rand() % 64;
const int yRand = rand() % 32;
int positive = rand() % 2;
m_properties.momentum.x = (1.0f - (2.0f * positive)) * (1.0 + static_cast<float>(xRand) / 120.0f);
m_properties.momentum.x = (1.0f - (2.0f * positive)) * (1.0 + static_cast<float>(xRand) / 120.0f) / 20.0;
positive = rand() % 2;
m_properties.momentum.y = (1.0f - (2.0f * positive)) * (1.0 + static_cast<float>(yRand) / 120.0f);
m_properties.momentum.y = (1.0f - (2.0f * positive)) * (1.0 + static_cast<float>(yRand) / 120.0f) / 20.0;
}
m_options.game = m_gaming;
m_options.absorbtionEnabled = m_gaming;
......@@ -278,14 +278,14 @@ void QPong::GameLayer::onGuiRender()
{
// GUI settings for the particle
ImGui::Begin("Particle Settings");
ImGui::DragFloat2("Start Position", glm::value_ptr(m_properties.position), 0.01f, -1.0f, 1.0f);
ImGui::DragFloat2("Start Position", glm::value_ptr(m_properties.position), 0.025f, -0.8f, 0.8f);
// Select initial momentum for particle at restart
ImGui::DragFloat2("Momentum [x,y]", glm::value_ptr(m_properties.momentum), 0.01f, -3.0f, 3.0f);
ImGui::DragFloat2("Momentum [x,y]", glm::value_ptr(m_properties.momentum), 0.001f, -0.1f, 0.1f);
ImGui::Checkbox("Random Momentum", &m_randomMomentum);
float sharpness = m_properties.sharpness;
if (ImGui::DragFloat("Sharpness", &sharpness, 1.0f, 5.0f, 1000.0f))
if (ImGui::DragFloat("Sharpness", &sharpness, 5.0f, 5.0f, 1000.0f))
{
m_properties.sharpness = sharpness;
}
......
......@@ -158,8 +158,8 @@ void Particle::initialiseParticleMomentum()
constexpr std::complex<double> ci{0.0, 1.0}; // complex number
const double hbar = m_properties.hbar;
const double A0 = m_properties.startValue;
const double px0 = m_properties.momentum.x / 20.0;
const double py0 = m_properties.momentum.y / 20.0;
const double px0 = m_properties.momentum.x;
const double py0 = m_properties.momentum.y;
const double x0 = m_properties.position.x;
const double y0 = m_properties.position.y;
const double lambda = m_properties.sharpness;
......
......@@ -95,9 +95,16 @@ void calculateSchroedingerPotential(float *potential, double *xAt, double *yAt,
void calculateGaussBox(float *potential, double *xAt, double *yAt, int arrayElements)
{
constexpr double grow = 2.0;
constexpr double grow = 0.1;
constexpr double scalePotential = 1.0;
for (int i{0}; i < arrayElements; ++i)
{
potential[i] = 1.0 / ((exp( -pow2(xAt[i]*grow) + -pow2(yAt[i]*grow))) * 5500.0);
auto x = xAt[i] * grow;
auto y = yAt[i] * grow;
auto d = sqrt(pow2(x) + pow2(y));
// V(x) = 1 / cosh^2(x) ~= 1 / (1/2 * (cosh(2x)+1))
auto V = 1.0 / ( 0.5 * (cosh(2.0 * d) + 1.0));
V *= scalePotential;
potential[i] = 1.0 - V;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment