Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Tristan Renon
motorPhaserVisualisationTool
Commits
7fd30596
Commit
7fd30596
authored
May 22, 2021
by
Tristan Renon
💬
Browse files
removed files from the index (now ignored)
parent
c0044f7b
Changes
1000
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
0 additions
and
575 deletions
+0
-575
.gitignore.txt
.gitignore.txt
+0
-3
Management/motorPhaser.pptx
Management/motorPhaser.pptx
+0
-0
Prog/Python/motorPhaser/.idea/.gitignore
Prog/Python/motorPhaser/.idea/.gitignore
+0
-3
Prog/Python/motorPhaser/.idea/inspectionProfiles/profiles_settings.xml
...otorPhaser/.idea/inspectionProfiles/profiles_settings.xml
+0
-6
Prog/Python/motorPhaser/.idea/misc.xml
Prog/Python/motorPhaser/.idea/misc.xml
+0
-4
Prog/Python/motorPhaser/.idea/modules.xml
Prog/Python/motorPhaser/.idea/modules.xml
+0
-8
Prog/Python/motorPhaser/.idea/motorPhaser.iml
Prog/Python/motorPhaser/.idea/motorPhaser.iml
+0
-10
Prog/Python/motorPhaser/.idea/vcs.xml
Prog/Python/motorPhaser/.idea/vcs.xml
+0
-6
Prog/Python/motorPhaser/2enhancedVector+circle.py
Prog/Python/motorPhaser/2enhancedVector+circle.py
+0
-40
Prog/Python/motorPhaser/2simpleVector+circle.py
Prog/Python/motorPhaser/2simpleVector+circle.py
+0
-40
Prog/Python/motorPhaser/3enhancedVector.py
Prog/Python/motorPhaser/3enhancedVector.py
+0
-51
Prog/Python/motorPhaser/__pycache__/multiVectorFinal.cpython-37.pyc
...n/motorPhaser/__pycache__/multiVectorFinal.cpython-37.pyc
+0
-0
Prog/Python/motorPhaser/allTogether.py
Prog/Python/motorPhaser/allTogether.py
+0
-125
Prog/Python/motorPhaser/arrowDrawing.py
Prog/Python/motorPhaser/arrowDrawing.py
+0
-25
Prog/Python/motorPhaser/circleDrawing.py
Prog/Python/motorPhaser/circleDrawing.py
+0
-24
Prog/Python/motorPhaser/colorFuck.py
Prog/Python/motorPhaser/colorFuck.py
+0
-11
Prog/Python/motorPhaser/doubleAnimation.py
Prog/Python/motorPhaser/doubleAnimation.py
+0
-46
Prog/Python/motorPhaser/fixedArrow.py
Prog/Python/motorPhaser/fixedArrow.py
+0
-72
Prog/Python/motorPhaser/main.py
Prog/Python/motorPhaser/main.py
+0
-16
Prog/Python/motorPhaser/multiVectorFinal.py
Prog/Python/motorPhaser/multiVectorFinal.py
+0
-85
No files found.
Too many changes to show.
To preserve performance only
1000 of 1000+
files are displayed.
Plain diff
Email patch
.gitignore.txt
deleted
100644 → 0
View file @
c0044f7b
Prog\Python\motorPhaser\.idea
Prog\Python\motorPhaser\__pycache__
Prog\Python\motorPhaser\venv
\ No newline at end of file
Management/motorPhaser.pptx
deleted
100644 → 0
View file @
c0044f7b
File deleted
Prog/Python/motorPhaser/.idea/.gitignore
deleted
100644 → 0
View file @
c0044f7b
# Default ignored files
/shelf/
/workspace.xml
Prog/Python/motorPhaser/.idea/inspectionProfiles/profiles_settings.xml
deleted
100644 → 0
View file @
c0044f7b
<component
name=
"InspectionProjectProfileManager"
>
<settings>
<option
name=
"USE_PROJECT_PROFILE"
value=
"false"
/>
<version
value=
"1.0"
/>
</settings>
</component>
\ No newline at end of file
Prog/Python/motorPhaser/.idea/misc.xml
deleted
100644 → 0
View file @
c0044f7b
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectRootManager"
version=
"2"
project-jdk-name=
"Python 3.9 (motorPhaser)"
project-jdk-type=
"Python SDK"
/>
</project>
\ No newline at end of file
Prog/Python/motorPhaser/.idea/modules.xml
deleted
100644 → 0
View file @
c0044f7b
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectModuleManager"
>
<modules>
<module
fileurl=
"file://$PROJECT_DIR$/.idea/motorPhaser.iml"
filepath=
"$PROJECT_DIR$/.idea/motorPhaser.iml"
/>
</modules>
</component>
</project>
\ No newline at end of file
Prog/Python/motorPhaser/.idea/motorPhaser.iml
deleted
100644 → 0
View file @
c0044f7b
<?xml version="1.0" encoding="UTF-8"?>
<module
type=
"PYTHON_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
>
<content
url=
"file://$MODULE_DIR$"
>
<excludeFolder
url=
"file://$MODULE_DIR$/venv"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</module>
\ No newline at end of file
Prog/Python/motorPhaser/.idea/vcs.xml
deleted
100644 → 0
View file @
c0044f7b
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$/../../.."
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
Prog/Python/motorPhaser/2enhancedVector+circle.py
deleted
100644 → 0
View file @
c0044f7b
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.animation
as
animation
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
8
,
8
))
ax
.
set
(
xlim
=
(
-
2
,
2
),
ylim
=
(
-
2
,
2
))
N
=
50
xSin
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
N
)
# start,stop,step
sin90
=
(
np
.
sin
(
xSin
),
np
.
cos
(
xSin
))
phaseShift
=
(
35
,
90
)
def
animate
(
i
):
ax
.
cla
()
#This one start at 0, 0
ax
.
arrow
(
0
,
0
,
np
.
sin
(
phaseShift
[
0
]
/
180
*
np
.
pi
)
*
sin90
[
0
][
i
],
np
.
cos
(
phaseShift
[
0
]
/
180
*
np
.
pi
)
*
sin90
[
0
][
i
],
head_width
=
.
1
,
head_length
=
.
1
,
fc
=
'blue'
,
ec
=
'blue'
)
#This one should start at the end of the first one
ax
.
arrow
(
np
.
sin
(
phaseShift
[
0
]
/
180
*
np
.
pi
)
*
sin90
[
0
][
i
],
np
.
cos
(
phaseShift
[
0
]
/
180
*
np
.
pi
)
*
sin90
[
0
][
i
],
np
.
sin
(
phaseShift
[
1
]
/
180
*
np
.
pi
)
*
sin90
[
1
][
i
],
np
.
cos
(
phaseShift
[
1
]
/
180
*
np
.
pi
)
*
sin90
[
1
][
i
],
head_width
=
.
1
,
head_length
=
.
1
,
fc
=
'red'
,
ec
=
'red'
)
# ax.arrow(0, 0,
# sin90[0][i], sin90[1][i],
# head_width=.1, head_length=.1, fc='green', ec='green')
ax
.
plot
(
np
.
sin
(
phaseShift
[
0
]
/
180
*
np
.
pi
)
*
sin90
[
0
][:
i
]
+
np
.
sin
(
phaseShift
[
1
]
/
180
*
np
.
pi
)
*
sin90
[
1
][:
i
],
np
.
cos
(
phaseShift
[
0
]
/
180
*
np
.
pi
)
*
sin90
[
0
][:
i
]
+
np
.
cos
(
phaseShift
[
1
]
/
180
*
np
.
pi
)
*
sin90
[
1
][:
i
])
ax
.
set
(
xlim
=
(
-
2
,
2
),
ylim
=
(
-
2
,
2
))
ani
=
animation
.
FuncAnimation
(
fig
,
animate
,
interval
=
20
,
frames
=
N
,
blit
=
False
,
save_count
=
50
)
plt
.
show
()
\ No newline at end of file
Prog/Python/motorPhaser/2simpleVector+circle.py
deleted
100644 → 0
View file @
c0044f7b
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.animation
as
animation
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
8
,
8
))
ax
.
set
(
xlim
=
(
-
2
,
2
),
ylim
=
(
-
2
,
2
))
N
=
50
xSin
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
N
)
# start,stop,step
sin90
=
(
np
.
sin
(
xSin
),
np
.
cos
(
xSin
))
def
animate
(
i
):
ax
.
cla
()
#This one start at 0, 0
ax
.
arrow
(
0
,
0
,
sin90
[
0
][
i
],
0
,
head_width
=
.
1
,
head_length
=
.
1
,
fc
=
'blue'
,
ec
=
'blue'
)
#This one should start at the end of the first one
ax
.
arrow
(
sin90
[
0
][
i
],
0
,
0
,
sin90
[
1
][
i
],
head_width
=
.
1
,
head_length
=
.
1
,
fc
=
'red'
,
ec
=
'red'
)
ax
.
arrow
(
0
,
0
,
sin90
[
0
][
i
],
sin90
[
1
][
i
],
head_width
=
.
1
,
head_length
=
.
1
,
fc
=
'green'
,
ec
=
'green'
)
ax
.
plot
(
sin90
[
0
][:
i
],
sin90
[
1
][:
i
])
ax
.
set
(
xlim
=
(
-
2
,
2
),
ylim
=
(
-
2
,
2
))
ani
=
animation
.
FuncAnimation
(
fig
,
animate
,
interval
=
20
,
frames
=
N
,
blit
=
False
,
save_count
=
50
)
plt
.
show
()
\ No newline at end of file
Prog/Python/motorPhaser/3enhancedVector.py
deleted
100644 → 0
View file @
c0044f7b
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.animation
as
animation
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
8
,
8
))
ax
.
set
(
xlim
=
(
-
2
,
2
),
ylim
=
(
-
2
,
2
))
N
=
50
nSamples
=
50
nPhases
=
3
phaseShift
=
(
0
,
120
,
240
)
def
generateSin
(
n
=
2
,
phaseShift
=
(
0
,
90
)):
xSin
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
nSamples
)
ret
=
list
()
for
i
in
range
(
n
):
ret
.
append
(
np
.
sin
(
xSin
+
phaseShift
[
i
]
/
180
*
np
.
pi
))
return
tuple
(
ret
)
generatedSin
=
generateSin
(
nPhases
,
phaseShift
)
def
animate
(
i
):
ax
.
cla
()
ax
.
arrow
(
0
,
0
,
np
.
sin
(
phaseShift
[
0
]
/
180
*
np
.
pi
)
*
generatedSin
[
0
][
i
],
np
.
cos
(
phaseShift
[
0
]
/
180
*
np
.
pi
)
*
generatedSin
[
0
][
i
],
head_width
=
.
1
,
head_length
=
.
1
,
fc
=
'blue'
,
ec
=
'blue'
)
#This one should start at the end of the first one
ax
.
arrow
(
np
.
sin
(
phaseShift
[
0
]
/
180
*
np
.
pi
)
*
generatedSin
[
0
][
i
],
np
.
cos
(
phaseShift
[
0
]
/
180
*
np
.
pi
)
*
generatedSin
[
0
][
i
],
np
.
sin
(
phaseShift
[
1
]
/
180
*
np
.
pi
)
*
generatedSin
[
1
][
i
],
np
.
cos
(
phaseShift
[
1
]
/
180
*
np
.
pi
)
*
generatedSin
[
1
][
i
],
head_width
=
.
1
,
head_length
=
.
1
,
fc
=
'red'
,
ec
=
'red'
)
#This one should start at the end of the first one
ax
.
arrow
(
np
.
sin
(
phaseShift
[
1
]
/
180
*
np
.
pi
)
*
generatedSin
[
1
][
i
]
+
np
.
sin
(
phaseShift
[
0
]
/
180
*
np
.
pi
)
*
generatedSin
[
0
][
i
],
np
.
cos
(
phaseShift
[
1
]
/
180
*
np
.
pi
)
*
generatedSin
[
1
][
i
]
+
np
.
cos
(
phaseShift
[
0
]
/
180
*
np
.
pi
)
*
generatedSin
[
0
][
i
],
np
.
sin
(
phaseShift
[
2
]
/
180
*
np
.
pi
)
*
generatedSin
[
2
][
i
],
np
.
cos
(
phaseShift
[
2
]
/
180
*
np
.
pi
)
*
generatedSin
[
2
][
i
],
head_width
=
.
1
,
head_length
=
.
1
,
fc
=
'green'
,
ec
=
'green'
)
ax
.
set
(
xlim
=
(
-
2
,
2
),
ylim
=
(
-
2
,
2
))
ani
=
animation
.
FuncAnimation
(
fig
,
animate
,
interval
=
20
,
frames
=
N
,
blit
=
False
,
save_count
=
50
)
plt
.
show
()
\ No newline at end of file
Prog/Python/motorPhaser/__pycache__/multiVectorFinal.cpython-37.pyc
deleted
100644 → 0
View file @
c0044f7b
File deleted
Prog/Python/motorPhaser/allTogether.py
deleted
100644 → 0
View file @
c0044f7b
import
matplotlib.pyplot
as
plt
import
matplotlib.animation
as
animation
import
numpy
as
np
nSamples
=
50
inputNPhases
=
5
# inputPhaseAmplitude = (0, 1, 1, 1, 1)
inputPhaseAmplitude
=
(
0
,
1.382
,
1.382
,
1.382
,
1.382
)
inputPhaseShiftMec
=
(
0
,
72
,
72
*
2
,
72
*
3
,
72
*
4
)
inputPhaseShiftReg
=
(
0
,
36
,
180
-
36
,
180
+
36
,
360
-
36
)
xSin
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
nSamples
)
# start,stop,step
sin90
=
(
np
.
sin
(
xSin
),
np
.
cos
(
xSin
))
def
generateSin
(
n
=
3
,
phaseShiftReg
=
None
,
phaseAmplitude
=
None
,
phaseShiftMec
=
None
):
# Generate things if user did not tell about them
if
phaseAmplitude
is
None
:
phaseAmplitude
=
np
.
ones
(
n
)
if
phaseShiftMec
is
None
:
if
n
==
2
:
phaseShiftMec
=
(
0
,
90
)
else
:
phaseShiftMec
=
np
.
linspace
(
0
,
360
,
n
,
endpoint
=
False
)
if
phaseShiftReg
is
None
:
phaseShiftReg
=
phaseShiftMec
# Make sure people gave valid parameters
assert
len
(
phaseShiftReg
)
==
n
,
"phaseShiftReg is not the same size as Phases (n)"
assert
len
(
phaseAmplitude
)
==
n
,
"phaseAmplitude is not the same size as Phases (n)"
assert
len
(
phaseShiftMec
)
==
n
,
"phaseShiftMec is not the same size as Phases (n)"
# Generate x (0 to 2pi)
xSin
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
nSamples
)
ret
=
list
()
# Generate power supply for coils
for
i
in
range
(
n
):
ret
.
append
(
phaseAmplitude
[
i
]
*
np
.
sin
(
xSin
+
phaseShiftReg
[
i
]
/
180
*
np
.
pi
))
return
tuple
(
ret
),
n
,
phaseShiftReg
,
phaseAmplitude
,
phaseShiftMec
,
xSin
generatedSin
,
nPhases
,
phaseShiftReg
,
phaseAmplitude
,
phaseShiftMec
,
xSin
=
generateSin
(
inputNPhases
,
inputPhaseShiftReg
,
inputPhaseAmplitude
,
inputPhaseShiftMec
)
def
create_plot
(
i
):
l1
,
=
i
.
plot
(
sin90
[
0
],
sin90
[
0
],
label
=
'$y=f_1(t)$'
)
arts
=
[
l1
]
return
arts
## return the artists created by `plt.plot()`
fig
,
(
ax1
,
ax2
,
ax3
)
=
plt
.
subplots
(
1
,
3
,
figsize
=
(
13
,
4
))
my_lines
=
[]
## array to keep track of the Line2D artists
l
=
create_plot
(
ax1
)
my_lines
+=
l
## add artists to array
l
=
create_plot
(
ax2
)
my_lines
+=
l
l
=
create_plot
(
ax3
)
my_lines
+=
l
def
animate
(
i
):
# Subplot 1
ax1
.
cla
()
sliding
=
[[
0
,
0
],
[
0
,
0
]]
plotX
=
np
.
zeros
(
i
)
plotY
=
np
.
zeros
(
i
)
for
j
in
range
(
nPhases
):
colors
=
next
(
ax1
.
_get_lines
.
prop_cycler
)[
'color'
]
# New start = sum of last starts
sliding
[
0
][
0
]
+=
sliding
[
1
][
0
]
sliding
[
0
][
1
]
+=
sliding
[
1
][
1
]
# New end = sin-cos (x-y) of mechanical multiplied by power supply
sliding
[
1
]
=
[
np
.
sin
(
phaseShiftMec
[
j
]
/
180
*
np
.
pi
)
*
generatedSin
[
j
][
i
],
np
.
cos
(
phaseShiftMec
[
j
]
/
180
*
np
.
pi
)
*
generatedSin
[
j
][
i
]]
ax1
.
arrow
(
sliding
[
0
][
0
],
sliding
[
0
][
1
],
sliding
[
1
][
0
],
sliding
[
1
][
1
],
head_width
=
.
1
,
head_length
=
.
1
,
fc
=
colors
,
ec
=
colors
)
# Needed to draw the ellipse
xTemp
=
np
.
sin
(
phaseShiftMec
[
j
]
/
180
*
np
.
pi
)
*
generatedSin
[
j
][:
i
]
yTemp
=
np
.
cos
(
phaseShiftMec
[
j
]
/
180
*
np
.
pi
)
*
generatedSin
[
j
][:
i
]
# Have to sum all sin in x and all cos in y (still for ellipse)
plotX
+=
xTemp
plotY
+=
yTemp
ax1
.
plot
(
plotX
,
plotY
,
color
=
'skyblue'
)
ax1
.
set
(
xlim
=
(
-
(
inputNPhases
+
1
)
/
2
,
(
inputNPhases
+
1
)
/
2
),
ylim
=
(
-
(
inputNPhases
+
1
)
/
2
,
(
inputNPhases
+
1
)
/
2
))
# Subplot 2
ax2
.
cla
()
sliding
=
[[
0
,
0
],
[
0
,
0
]]
for
j
in
range
(
nPhases
):
colors
=
next
(
ax2
.
_get_lines
.
prop_cycler
)[
'color'
]
sliding
[
0
]
+=
sliding
[
1
]
sliding
[
1
]
=
[
np
.
sin
(
phaseShiftMec
[
j
]
/
180
*
np
.
pi
)
*
generatedSin
[
j
][
i
],
np
.
cos
(
phaseShiftMec
[
j
]
/
180
*
np
.
pi
)
*
generatedSin
[
j
][
i
]]
ax2
.
arrow
(
sliding
[
0
][
0
],
sliding
[
0
][
1
],
sliding
[
1
][
0
],
sliding
[
1
][
1
],
head_width
=
.
1
,
head_length
=
.
1
,
fc
=
colors
,
ec
=
colors
)
limit
=
max
(
phaseAmplitude
)
*
1.1
ax2
.
set
(
xlim
=
(
-
limit
,
limit
),
ylim
=
(
-
limit
,
limit
))
# Subplot 3
ax3
.
cla
()
for
j
in
range
(
nPhases
):
plt
.
plot
(
xSin
,
generatedSin
[
j
])
plt
.
axvline
(
x
=
xSin
[
i
],
color
=
'black'
)
limit
=
max
(
phaseAmplitude
)
*
1.1
ax3
.
set
(
xlim
=
(
0
,
2
*
np
.
pi
),
ylim
=
(
-
limit
,
limit
))
ani
=
animation
.
FuncAnimation
(
fig
,
animate
,
interval
=
20
,
frames
=
nSamples
,
blit
=
False
,
save_count
=
nSamples
)
plt
.
show
()
\ No newline at end of file
Prog/Python/motorPhaser/arrowDrawing.py
deleted
100644 → 0
View file @
c0044f7b
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.animation
as
animation
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
8
,
8
))
ax
.
set
(
xlim
=
(
-
2
,
2
),
ylim
=
(
-
2
,
2
))
N
=
50
xSin
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
N
)
# start,stop,step
sin
=
np
.
sin
(
xSin
)
def
animate
(
i
):
ax
.
cla
()
#This one start at 0, 0
ax
.
arrow
(
0
,
0
,
sin
[
i
],
0
,
head_width
=
.
1
,
head_length
=
.
1
,
fc
=
'blue'
,
ec
=
'blue'
)
ax
.
set
(
xlim
=
(
-
2
,
2
),
ylim
=
(
-
2
,
2
))
ani
=
animation
.
FuncAnimation
(
fig
,
animate
,
interval
=
20
,
frames
=
N
,
blit
=
False
,
save_count
=
50
)
plt
.
show
()
\ No newline at end of file
Prog/Python/motorPhaser/circleDrawing.py
deleted
100644 → 0
View file @
c0044f7b
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.animation
as
animation
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
8
,
8
))
ax
.
set
(
xlim
=
(
-
1.5
,
1.5
),
ylim
=
(
-
1.5
,
1.5
))
N
=
50
xSin
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
N
)
# start,stop,step
sin90
=
(
np
.
sin
(
xSin
),
np
.
cos
(
xSin
))
line
,
=
ax
.
plot
(
sin90
[
0
],
sin90
[
1
])
def
animate
(
i
):
line
.
set_data
(
sin90
[
0
][:
i
],
sin90
[
1
][:
i
])
return
line
,
ani
=
animation
.
FuncAnimation
(
fig
,
animate
,
interval
=
20
,
frames
=
N
,
blit
=
True
,
save_count
=
N
)
plt
.
show
()
\ No newline at end of file
Prog/Python/motorPhaser/colorFuck.py
deleted
100644 → 0
View file @
c0044f7b
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.animation
as
animation
from
matplotlib.pyplot
import
cm
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
8
,
8
))
ax
.
set
(
xlim
=
(
0
,
2
*
np
.
pi
),
ylim
=
(
-
2
,
2
))
for
i
in
range
(
3
):
print
(
next
(
ax
.
_get_lines
.
prop_cycler
)[
'color'
])
\ No newline at end of file
Prog/Python/motorPhaser/doubleAnimation.py
deleted
100644 → 0
View file @
c0044f7b
import
matplotlib.pyplot
as
plt
import
matplotlib.animation
as
animation
import
numpy
as
np
nSamples
=
50
xSin
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
nSamples
)
# start,stop,step
sin90
=
(
np
.
sin
(
xSin
),
np
.
cos
(
xSin
))
def
create_plot
(
i
):
l1
,
=
i
.
plot
(
sin90
[
0
],
sin90
[
0
],
label
=
'$y=f_1(t)$'
)
arts
=
[
l1
]
return
arts
## return the artists created by `plt.plot()`
fig
,
(
ax1
,
ax2
,
ax3
)
=
plt
.
subplots
(
1
,
3
,
figsize
=
(
12
,
4
))
my_lines
=
[]
## array to keep track of the Line2D artists
l
=
create_plot
(
ax1
)
my_lines
+=
l
## add artists to array
l
=
create_plot
(
ax2
)
my_lines
+=
l
l
=
create_plot
(
ax3
)
my_lines
+=
l
# Tweak spacing between subplots to prevent labels from overlapping
plt
.
subplots_adjust
(
hspace
=
0.5
)
print
(
my_lines
)
def
animate
(
i
):
## in this examples, i takes values 0-10 by steps of 0.01 (the frames in the animation call)
## and will represent the frequency of the 2nd wave in the top subplot
# update the content of the Line2D objects
my_lines
[
0
].
set_data
(
sin90
[
0
][:
i
],
sin90
[
1
][:
i
])
ax1
.
set
(
xlim
=
(
-
2
,
2
),
ylim
=
(
-
2
,
2
))
my_lines
[
1
].
set_data
(
sin90
[
0
][:
i
],
sin90
[
1
][:
i
])
my_lines
[
2
].
set_data
(
sin90
[
0
][:
i
],
sin90
[
1
][:
i
])
return
my_lines
## return updated artists
ani
=
animation
.
FuncAnimation
(
fig
,
animate
,
interval
=
20
,
frames
=
nSamples
,
blit
=
False
,
save_count
=
nSamples
)
plt
.
show
()
\ No newline at end of file
Prog/Python/motorPhaser/fixedArrow.py
deleted
100644 → 0
View file @
c0044f7b
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.animation
as
animation
from
matplotlib.pyplot
import
cm
nSamples
=
50
nPhases
=
10
# phaseAmplitude = (0, 1.382, 1.382, 1.382, 1.382)
# phaseShiftMec = (0, 72, 72*2, 72*3, 72*4)
# phaseShiftReg = (0, 36, 180-36, 180+36, 360-36)
# phaseAmplitude = (1, 1, 1, 1, 1)
# phaseShiftMec = (0, 72, 72*2, 72*3, 72*4)
# phaseShiftReg = phaseShiftMec
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
8
,
8
))
ax
.
set
(
xlim
=
(
-
2
,
2
),
ylim
=
(
-
2
,
2
))
def
generateSin
(
n
=
3
,
phaseShiftReg
=
None
,
phaseAmplitude
=
None
,
phaseShiftMec
=
None
):
# Generate things if user did not tell about them
if
phaseAmplitude
is
None
:
phaseAmplitude
=
np
.
ones
(
n
)
if
phaseShiftMec
is
None
:
if
n
==
2
:
phaseShiftMec
=
(
0
,
90
)
else
:
phaseShiftMec
=
np
.
linspace
(
0
,
360
,
n
,
endpoint
=
False
)
if
phaseShiftReg
is
None
:
phaseShiftReg
=
phaseShiftMec
# Make sure people gave valid parameters
assert
len
(
phaseShiftReg
)
==
n
,
"phaseShiftReg is not the same size as Phases (n)"
assert
len
(
phaseAmplitude
)
==
n
,
"phaseAmplitude is not the same size as Phases (n)"
assert
len
(
phaseShiftMec
)
==
n
,
"phaseShiftMec is not the same size as Phases (n)"
# Generate x (0 to 2pi)
xSin
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
nSamples
)
ret
=
list
()
# Generate power supply for coils
for
i
in
range
(
n
):
ret
.
append
(
phaseAmplitude
[
i
]
*
np
.
sin
(
xSin
+
phaseShiftReg
[
i
]
/
180
*
np
.
pi
))
return
tuple
(
ret
),
phaseShiftMec
,
phaseAmplitude
# generatedSin, phaseShiftMec, phaseAmplitude = generateSin(n=nPhases, phaseShiftReg=phaseShiftReg, phaseAmplitude=phaseAmplitude, phaseShiftMec=phaseShiftMec)
generatedSin
,
phaseShiftMec
,
phaseAmplitude
=
generateSin
(
n
=
nPhases
)
def
animate
(
i
):
ax
.
cla
()
sliding
=
[[
0
,
0
],
[
0
,
0
]]
for
j
in
range
(
nPhases
):
colors
=
next
(
ax
.
_get_lines
.
prop_cycler
)[
'color'
]
sliding
[
0
]
+=
sliding
[
1
]
sliding
[
1
]
=
[
np
.
sin
(
phaseShiftMec
[
j
]
/
180
*
np
.
pi
)
*
generatedSin
[
j
][
i
],
np
.
cos
(
phaseShiftMec
[
j
]
/
180
*
np
.
pi
)
*
generatedSin
[
j
][
i
]]
ax
.
arrow
(
sliding
[
0
][
0
],
sliding
[
0
][
1
],
sliding
[
1
][
0
],
sliding
[
1
][
1
],
head_width
=
.
1
,
head_length
=
.
1
,
fc
=
colors
,
ec
=
colors
)
limit
=
max
(
phaseAmplitude
)
*
1.1
ax
.
set
(
xlim
=
(
-
limit
,
limit
),
ylim
=
(
-
limit
,
limit
))
ani
=
animation
.
FuncAnimation
(
fig
,
animate
,
interval
=
20
,
frames
=
nSamples
,
blit
=
False
,
save_count
=
nSamples
)
plt
.
show
()
Prog/Python/motorPhaser/main.py
deleted
100644 → 0
View file @
c0044f7b
# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
def
print_hi
(
name
):
# Use a breakpoint in the code line below to debug your script.
print
(
f
'Hi,
{
name
}
'
)
# Press Ctrl+F8 to toggle the breakpoint.
# Press the green button in the gutter to run the script.
if
__name__
==
'__main__'
:
print_hi
(
'PyCharm'
)
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
Prog/Python/motorPhaser/multiVectorFinal.py
deleted
100644 → 0
View file @
c0044f7b
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.animation
as
animation
from
matplotlib.pyplot
import
cm
nSamples
=
50
inputNPhases
=
5
inputPhaseAmplitude
=
(
0
,
1
,
1
,
1
,
1
)
# inputPhaseAmplitude = (0, 1.382, 1.382, 1.382, 1.382)
inputPhaseShiftMec
=
(
0
,
72
,
72
*
2
,
72
*
3
,
72
*
4
)
inputPhaseShiftReg
=
(
0
,
36
,
180
-
36
,
180
+
36
,
360
-
36
)
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
8
,
8
))
ax
.
set
(
xlim
=
(
-
(
inputNPhases
+
1
)
/
2
,
(
inputNPhases
+
1
)
/
2
),
ylim
=
(
-
(
inputNPhases
+
1
)
/
2
,
(
inputNPhases
+
1
)
/
2
))
def
generateSin
(
n
=
3
,
phaseShiftReg
=
None
,
phaseAmplitude
=
None
,
phaseShiftMec
=
None
):
# Generate things if user did not tell about them
if
phaseAmplitude
is
None
:
phaseAmplitude
=
np
.
ones
(
n
)
if
phaseShiftMec
is
None
:
if
n
==
2
:
phaseShiftMec
=
(
0
,
90
)
else
:
phaseShiftMec
=
np
.
linspace
(
0
,
360
,
n
,
endpoint
=
False
)
if
phaseShiftReg
is
None
:
phaseShiftReg
=
phaseShiftMec
# Make sure people gave valid parameters
assert
len
(
phaseShiftReg
)
==
n
,
"phaseShiftReg is not the same size as Phases (n)"
assert
len
(
phaseAmplitude
)
==
n
,
"phaseAmplitude is not the same size as Phases (n)"
assert
len
(
phaseShiftMec
)
==
n
,
"phaseShiftMec is not the same size as Phases (n)"
# Generate x (0 to 2pi)
xSin
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
nSamples
)
ret
=
list
()
# Generate power supply for coils
for
i
in
range
(
n
):
ret
.
append
(
phaseAmplitude
[
i
]
*
np
.
sin
(
xSin
+
phaseShiftReg
[
i
]
/
180
*
np
.
pi
))
return
tuple
(
ret
),
n
,
phaseShiftReg
,
phaseAmplitude
,
phaseShiftMec