Superfish
superfish.Superfish
Superfish(
automesh=None,
problem="fish",
use_tempdir=True,
use_container="auto",
container_method=None,
interactive=False,
workdir=None,
verbose=True,
)
Interface to the Poisson Superfish programs.
Manages a working directory, runs the Poisson Superfish programs (natively on Windows, or through a container elsewhere), and parses their output.
Attributes:
| Name | Type | Description |
|---|---|---|
input |
dict
|
Input data with |
output |
dict
|
Parsed output, filled by :meth: |
path |
str
|
Working directory where the programs run. |
use_container |
bool
|
Whether commands run through a container. |
container_method |
str or None
|
Selected container orchestration method. |
Poisson-Superfish object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
automesh
|
str
|
Path to an automesh input file. If given, it is loaded and the object is configured to run. |
None
|
problem
|
(fish, poisson)
|
Type of problem to run. |
"fish"
|
use_tempdir
|
bool
|
Run in a temporary directory instead of in place. |
True
|
use_container
|
auto or bool
|
Whether to run through a container. "auto" uses the native executables on Windows and a container elsewhere. |
'auto'
|
container_method
|
(docker, shifter, singularity)
|
Container orchestration method. If not given, defaults to the PYSUPERFISH_CONTAINER_METHOD environment variable; if that is also unset, the first available method is auto-detected: Singularity with an existing image, then Docker, then Shifter, then Singularity without an image. |
"docker"
|
interactive
|
bool
|
Run the container in interactive (X11) mode. macOS only. |
False
|
workdir
|
str
|
Base directory for the working directory. |
None
|
verbose
|
bool
|
Print progress messages. |
True
|
Source code in superfish/superfish.py
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 | |
Attributes
superfish.Superfish.automesh_name
property
automesh_name
Name of the automesh input file, <basename>.AM.
superfish.Superfish.basename
property
basename
Base name of the problem, from the automesh file name.
superfish.Superfish.container_command
property
container_command
Command template for the selected container method, or None.
Methods:
superfish.Superfish.configure
configure()
Configure the working directory to run in.
Creates a temporary directory when use_tempdir is set;
otherwise runs in workdir or in place.
Source code in superfish/superfish.py
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 | |
superfish.Superfish.container_run_cmd
container_run_cmd(*args)
Form the run command string for the container.
The container data should live in its /data/ folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
str
|
Program name and arguments, e.g. |
()
|
Returns:
| Type | Description |
|---|---|
str
|
The full shell command. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no container method is available. |
Source code in superfish/superfish.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 | |
superfish.Superfish.fieldmesh
fieldmesh(zmin=-100, zmax=100, nz=0, dz=0, rmin=0, rmax=100, nr=0, dr=0)
Interpolate the field over a grid, returning a FieldMesh.
Similar to :meth:interpolate, but input units are in meters.
Various combinations of the spacings and grid point numbers
nz, dz, nr, dr can be used. If neither is
specified, a default of 100 grid points will be used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zmin
|
float
|
z extent of the grid, in meters. |
-100
|
zmax
|
float
|
z extent of the grid, in meters. |
-100
|
nz
|
int
|
Number of z points. |
0
|
dz
|
float
|
z spacing, in meters. Overrides |
0
|
rmin
|
float
|
Radial extent of the grid, in meters. |
0
|
rmax
|
float
|
Radial extent of the grid, in meters. |
0
|
nr
|
int
|
Number of radius points. |
0
|
dr
|
float
|
Radial spacing, in meters. Overrides |
0
|
Returns:
| Type | Description |
|---|---|
FieldMesh
|
An openPMD-beamphysics FieldMesh object. |
Source code in superfish/superfish.py
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 323 | |
superfish.Superfish.interpolate
interpolate(zmin=-1000, zmax=1000, nz=100, rmin=0, rmax=0, nr=1)
Interpolate the field over a grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zmin
|
float
|
z extent of the grid, in the problem's input units. |
-1000
|
zmax
|
float
|
z extent of the grid, in the problem's input units. |
-1000
|
nz
|
int
|
Number of z points. |
100
|
rmin
|
float
|
Radial extent of the grid, in the problem's input units. |
0
|
rmax
|
float
|
Radial extent of the grid, in the problem's input units. |
0
|
nr
|
int
|
Number of radius points. |
1
|
Returns:
| Type | Description |
|---|---|
FishT7Data or PoissonT7Data
|
t7data dict, as returned by
:func: |
Source code in superfish/superfish.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | |
superfish.Superfish.load_input
load_input(input_filePath)
Load an automesh input file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_filePath
|
str
|
Path to the automesh (.AM) file. |
required |
Source code in superfish/superfish.py
512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |
superfish.Superfish.load_output
load_output()
Load and parse the SFO output file into .output["sfo"].
Source code in superfish/superfish.py
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | |
superfish.Superfish.param
param(key)
Look up a parameter from the readback in the SFO file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Variable or Constant name, e.g. |
required |
Returns:
| Type | Description |
|---|---|
int or float
|
The parameter value. |
Source code in superfish/superfish.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
superfish.Superfish.param_info
param_info(key)
Look up the description of a parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Variable or Constant name, e.g. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The parameter description. |
Source code in superfish/superfish.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
superfish.Superfish.plot_wall
plot_wall(units='original', **kwargs)
Plot the problem geometry from the parsed wall segments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
units
|
(original, cm)
|
Units for the plot axes. |
"original"
|
**kwargs
|
Any
|
Passed to :func: |
{}
|
Source code in superfish/superfish.py
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 | |
superfish.Superfish.run
run()
Write input, run the problem, and load the output.
Runs autofish for fish problems, or the
automesh/poisson/sfo chain for poisson problems.
Source code in superfish/superfish.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
superfish.Superfish.run_cmd
run_cmd(*cmds, **kwargs)
Run a Superfish program in the working directory.
Output is appended to output.log in the working directory when
running through a container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*cmds
|
str
|
Program name and arguments, e.g. |
()
|
**kwargs
|
Any
|
Passed to |
{}
|
Returns:
| Type | Description |
|---|---|
int or CompletedProcess
|
The return code (container), or the completed process (native Windows). |
Examples:
>>> sf.run_cmd("automesh", "TEST.AM", timeout=1)
Source code in superfish/superfish.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 | |
superfish.Superfish.vprint
vprint(*args)
Print only when verbose is enabled.
Source code in superfish/superfish.py
578 579 580 581 | |
superfish.Superfish.windows_run_cmd
windows_run_cmd(*args)
Form the run command string for the native Windows executables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
str
|
Program name and arguments, e.g. |
()
|
Returns:
| Type | Description |
|---|---|
str
|
The full command. |
Source code in superfish/superfish.py
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 | |
superfish.Superfish.write_input
write_input()
Write the automesh input file from .input["automesh"].
Source code in superfish/superfish.py
568 569 570 571 572 573 574 575 576 | |