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

save state

parent abb54962
Branches
No related tags found
No related merge requests found
...@@ -153,7 +153,6 @@ void Particle::manipulateParticleInPosition(int indexFrom, int indexTo) ...@@ -153,7 +153,6 @@ void Particle::manipulateParticleInPosition(int indexFrom, int indexTo)
{ {
double cx = -pOneX + x; double cx = -pOneX + x;
cx = cx * (M_PI / 2.0) / (1.0 + pOneX); cx = cx * (M_PI / 2.0) / (1.0 + pOneX);
cx = cx / 20000000000.0;
double dif = removeParticle(index, cx); double dif = removeParticle(index, cx);
sumScorePlayerTwo += dif; sumScorePlayerTwo += dif;
} }
...@@ -161,16 +160,16 @@ void Particle::manipulateParticleInPosition(int indexFrom, int indexTo) ...@@ -161,16 +160,16 @@ void Particle::manipulateParticleInPosition(int indexFrom, int indexTo)
{ {
double cx = x - pTwoX; double cx = x - pTwoX;
cx = cx * (M_PI / 2.0) / (1.0 - pTwoX); cx = cx * (M_PI / 2.0) / (1.0 - pTwoX);
cx = cx / 20000000000.0;
double dif = removeParticle(index, cx); double dif = removeParticle(index, cx);
sumScorePlayerOne += dif; sumScorePlayerOne += dif;
} }
double playerOneBat = batPotential(x, y, m_players[Player::Id::One]->getPosition()); double playerOneBat = batPotential(x, y, m_players[Player::Id::One]->getPosition());
double playerTwoBat = batPotential(x, y, m_players[Player::Id::Two]->getPosition()); double playerTwoBat = batPotential(x, y, m_players[Player::Id::Two]->getPosition());
double horizontalBorders = sqr(y) * sqr(y) * sqr(y) * sqr(y) * 0.01; double horizontalBorders = sqr(y) * sqr(y) * sqr(y) * sqr(y) * 0.01;
std::complex<double> tmp = m_psi[index] * exp(-Ci * dt / hbar * (playerOneBat + playerTwoBat + horizontalBorders)); auto potentialSum = playerOneBat + playerTwoBat + horizontalBorders;
m_psi[index] = tmp; auto tmpPsi = m_psi[index] * exp(-Ci * dt / hbar * potentialSum);
m_bufPositionRepresentation->updateAt(index, tmp * 125.0, (playerOneBat + playerTwoBat + horizontalBorders) * 150); m_psi[index] = tmpPsi;
m_bufPositionRepresentation->updateAt(index, tmpPsi * 125.0, potentialSum * 150);
} }
m_players[Player::Id::One]->addScore(sumScorePlayerOne); m_players[Player::Id::One]->addScore(sumScorePlayerOne);
m_players[Player::Id::Two]->addScore(sumScorePlayerTwo); m_players[Player::Id::Two]->addScore(sumScorePlayerTwo);
...@@ -181,13 +180,13 @@ double flattenMomentum(double x, double y) ...@@ -181,13 +180,13 @@ double flattenMomentum(double x, double y)
{ {
double distanceToCenter = sqr(x) + sqr(y); double distanceToCenter = sqr(x) + sqr(y);
constexpr double offset = 0.012; constexpr double offset = 0.012;
if (distanceToCenter < offset) if (distanceToCenter > offset)
{ {
return 1.0; return 1.0 / (1.0 + (distanceToCenter * 2.5));
} }
else else
{ {
return 1.0 / (1.0 + (distanceToCenter * 2.5)); return 1.0;
} }
} }
...@@ -195,7 +194,9 @@ double flattenMomentum(double x, double y) ...@@ -195,7 +194,9 @@ double flattenMomentum(double x, double y)
const double pxAt(int ix) const double pxAt(int ix)
{ {
if (ix > QPong::arrayWidth / 2) if (ix > QPong::arrayWidth / 2)
{
ix -= QPong::arrayWidth; ix -= QPong::arrayWidth;
}
return ix * M_PI * hbar; return ix * M_PI * hbar;
} }
...@@ -203,7 +204,9 @@ const double pxAt(int ix) ...@@ -203,7 +204,9 @@ const double pxAt(int ix)
const double pyAt(int iy) const double pyAt(int iy)
{ {
if (iy > QPong::arrayHeight / 2) if (iy > QPong::arrayHeight / 2)
{
iy -= QPong::arrayHeight; iy -= QPong::arrayHeight;
}
return iy * M_PI * hbar; return iy * M_PI * hbar;
} }
...@@ -217,7 +220,8 @@ void Particle::moveStep(int indexFrom, int indexTo) ...@@ -217,7 +220,8 @@ void Particle::moveStep(int indexFrom, int indexTo)
constexpr double m = 1.0; constexpr double m = 1.0;
constexpr double N = 1.0 / QPong::arraySize; constexpr double N = 1.0 / QPong::arraySize;
double E = (sqr(px) + sqr(py)) / (2.0 * m); double E = (sqr(px) + sqr(py)) / (2.0 * m);
m_psi[i] *= exp(-Ci * dt / hbar * E) * N * flattenMomentum(px, py); auto f = flattenMomentum(px, py);
m_psi[i] *= exp(-Ci * dt / hbar * E) * N * f;
// m_psi[i] = flattenMomentum(px, py) * 0.00001; // m_psi[i] = flattenMomentum(px, py) * 0.00001;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment