CommandWrapper
lume.base.CommandWrapper
Bases: Base
Interface for LUME-compatible code.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_file |
str, optional
|
The input file to be used, by default None |
None
|
initial_particles |
dict, optional
|
Initial Particle metadata to be used, by default None |
None
|
command |
str, optional
|
The command to be executed by this wrapper. E.g. ImpactTexe
If not specified, the class attribute |
None
|
command_mpi |
str, optional
|
The command to be executed by this wrapper when using MPI. E.g. ImpactTexe-mpi
If not specified, the class attribute |
None
|
use_mpi |
bool, optional
|
Whether or not to use MPI when running this code, by default False |
False
|
mpi_run |
str, optional
|
The command syntax to invoke mpirun. If not specified, the class attribute |
''
|
use_temp_dir |
bool, optional
|
Whether or not to use a temporary directory to run the process, by default True |
True
|
workdir |
str, optional
|
The work directory to be used, by default None |
None
|
verbose |
bool, optional
|
Whether or not to produce verbose output, by default False |
False
|
timeout |
float, optional
|
The timeout in seconds to be used, by default None |
None
|
Source code in lume/base.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 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 360 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 386 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 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 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 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 |
|
command
writable
property
Get or set the command to be executed. Defaults to COMMAND
.
command_mpi
writable
property
Get or set the command to be executed when running with MPI. Defaults to COMMAND_MPI
.
mpi_run
writable
property
The command syntax to invoke mpirun. If not specified, the class attribute MPI_RUN
is used.
This is expected to be a formated string taking as parameters the number of processors (nproc) and
the command to be executed (command_mpi).
path
writable
property
The base path used by the code to manipulate files.
use_mpi
writable
property
Whether or not MPI should be used if supported.
use_temp_dir
property
Whether or not the code is using temporary dir to run.
Returns:
Type | Description |
---|---|
bool
|
workdir
writable
property
Get or set the working directory
from_archive(archive_h5)
classmethod
Class method to return a new instance via restore of an archive file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
archive_h5 |
str or h5py.File
|
The filename or handle to HDF5 file in which to write the information. |
required |
Returns:
Name | Type | Description |
---|---|---|
c |
object
|
An instance of the class with information from the archive file. |
Source code in lume/base.py
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
|
get_run_script(write_to_path=True)
Assembles the run script. Optionally writes a file 'run' with this line to path.
This expect to run with .path as the cwd.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
write_to_path |
bool
|
Whether or not to write the script to the path. |
True
|
Returns:
Name | Type | Description |
---|---|---|
runscript |
str
|
The script to run the command. |
Source code in lume/base.py
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
|
input_parser(path)
staticmethod
abstractmethod
Invoke the specialized input parser and returns the input dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
Path to the input file |
required |
Returns:
Name | Type | Description |
---|---|---|
input |
dict
|
The input dictionary |
Source code in lume/base.py
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
|
load_input(input_filepath, **kwargs)
Invoke the input_parser
with the given input file path as argument.
This method sets the input property to the contents of the input file after the parser.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_filepath |
str
|
The input file path |
required |
kwargs |
dict
|
Support for extra arguments. |
{}
|
Source code in lume/base.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
|
load_output(**kwargs)
abstractmethod
Reads and load into .output
the outputs generated by the code.
Source code in lume/base.py
575 576 577 578 579 580 |
|
plot(y=[], x=None, xlim=None, ylim=None, ylim2=None, y2=[], nice=True, include_layout=True, include_labels=False, include_particles=True, include_legend=True, return_figure=False)
abstractmethod
Plots output multiple keys.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
y |
list
|
List of keys to be displayed on the Y axis |
[]
|
x |
str
|
Key to be displayed as X axis |
None
|
xlim |
list
|
Limits for the X axis |
None
|
ylim |
list
|
Limits for the Y axis |
None
|
ylim2 |
list
|
Limits for the secondary Y axis |
None
|
y2 |
list
|
List of keys to be displayed on the secondary Y axis |
[]
|
nice |
bool
|
Whether or not a nice SI prefix and scaling will be used to make the numbers reasonably sized. Default: True |
True
|
include_layout |
bool
|
Whether or not to include a layout plot at the bottom. Default: True |
True
|
include_labels |
bool
|
Whether or not the layout will include element labels. Default: False |
False
|
include_particles |
bool
|
Whether or not to plot the particle statistics as dots. Default: True |
True
|
include_legend |
bool
|
Whether or not the plot should include the legend. Default: True |
True
|
return_figure |
bool
|
Whether or not to return the figure object for further manipulation. Default: True |
False
|
kwargs |
dict
|
Extra arguments can be passed to the specific plotting function. |
required |
Returns:
Name | Type | Description |
---|---|---|
fig |
matplotlib.pyplot.figure.Figure
|
The plot figure for further customizations or |
Source code in lume/base.py
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 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
|
reset()
Reset this object to its initial state.
Source code in lume/base.py
582 583 584 585 586 587 588 589 590 |
|
setup_workdir(workdir, cleanup=True)
Set up the work directory if use_temp_dir
is set.
workdir and use_temp_dir: Set up temorary directory inside workdir
Parameters:
Name | Type | Description | Default |
---|---|---|---|
workdir |
str
|
The directory name. |
required |
cleanup |
bool
|
Whether or not to remove the directory at exit. Defaults to True. |
True
|
Source code in lume/base.py
606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 |
|
write_input(input_filename)
abstractmethod
Write the input parameters into the file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_filename |
str
|
The file in which to write the input parameters |
required |
Source code in lume/base.py
527 528 529 530 531 532 533 534 535 536 537 |
|