Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
qpong
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Armin Co
qpong
Commits
0c03347e
Commit
0c03347e
authored
5 years ago
by
Armin Co
Browse files
Options
Downloads
Patches
Plain Diff
save state
parent
abb54962
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
qpong_core/Particle.cpp
+13
-9
13 additions, 9 deletions
qpong_core/Particle.cpp
with
13 additions
and
9 deletions
qpong_core/Particle.cpp
+
13
−
9
View file @
0c03347e
...
@@ -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;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment