Trajectory
trajectory
trajectory
Base class of trajectory classes: - Trajectory2D - Trajectory3D
Methods
- _prepare_plot: Prepares the plots.
- _scatter_start_point: Scatter all the start points.
- _scatter_trajectory: Scatter all the trajectories.
- _plot_lines: Plots the lines of all the trajectories.
- _create_sliders_plot: Creates the sliders plot.
- thermalize: Adds thermalization steps and random initial position.
- initial_position: Adds a trajectory with the given initial position.
- plot: Prepares the plots and computes the values. Returns the axis and the figure.
- add_slider: Adds a
Slider
for thedF
function. - _calculate_values: Computes the trajectories.
Source code in phaseportrait/trajectories/trajectory.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
|
__init__(dF, dimension, *, Range=None, dF_args={}, n_points=10000, runge_kutta_step=0.01, runge_kutta_freq=1, **kargs)
Creates an instance of trajectory
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dF |
callable)
|
A dF type function. |
required |
dimension |
The number of dimensions in which the trajectory is calculated. Must equal |
required | |
Range |
Union[float,list], default=None)
|
Range of every coordinate in the graphs. |
None
|
dF_args |
dict)
|
If necesary, must contain the kargs for the |
{}
|
n_points |
int, default=10000 )
|
Number of positions to be saved for every trajectory. |
10000
|
runge_kutta_step |
float, default=0.1)
|
Step of 'time' in the Runge-Kutta method. |
0.01
|
runge_kutta_freq |
int)
|
Number of times |
1
|
lines |
bool, defaullt=True)
|
Must be |
required |
Titulo |
str)
|
Title of the plot. |
required |
color |
str)
|
Matplotlib |
required |
size |
float)
|
Size of the scattered points. |
required |
thermalization |
int)
|
Thermalization steps before points saved. |
required |
mark_start_point |
bool)
|
Marks the start position if True. |
required |
Source code in phaseportrait/trajectories/trajectory.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
add_slider(param_name, *, valinit=None, valstep=0.1, valinterval=10)
Adds a Slider
for the dF
function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param_name |
str)
|
Name of the variable. Must be in the |
required |
valinit |
float, defautl=None
|
Initial position of the Slider |
None
|
valinterval |
Union[float,list], default=10
|
Min and max value for the param range. |
10
|
valstep |
float, default=0.1
|
Separation between consecutive values in the param range. |
0.1
|
Source code in phaseportrait/trajectories/trajectory.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
|
initial_position(*args, color=None, **kargs)
Adds a initial position for the computation. More than one can be added.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
Union[float, list[2], list[3]], optional)
|
Initial position for the computation. If None, a random position is chosen. |
()
|
Kargs
color (str|None): If a color is given it is used to plot that trajectory. If None the speed is used to color the line/dots.
Example:
This example generates 2 circles with diferent radius.
def Circle(x,y,*, w=1, z=1):
return w*y, -z*x
circle = Trayectoria2D(Circle, n_points=1300, size=2, mark_start_position=True, Titulo='Just a circle')
circle.initial_position(1,1)
circle.initial_position(2,2)
Source code in phaseportrait/trajectories/trajectory.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
initial_positions(*positions, **kargs)
Adds initial positions for the computation.
Calls trajectory.initial_position
for each position given.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
postitions |
list, list[list]
|
Initial positions for the computation. |
required |
Source code in phaseportrait/trajectories/trajectory.py
181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
plot(color=None, labels=False, grid=False, **kargs)
Prepares the plots and computes the values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color |
str)
|
Matplotlib |
None
|
labels |
str)
|
Label the initial positions |
False
|
Returns:
Type | Description |
---|---|
tuple(matplotlib Figure, matplotlib Axis)
|
|
Source code in phaseportrait/trajectories/trajectory.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
thermalize(*, thermalization_steps=200)
Shortcut to:
self.thermalization = thermalization_steps
self.initial_position()
Source code in phaseportrait/trajectories/trajectory.py
112 113 114 115 116 117 118 119 120 121 122 123 124 |
|