asaf.mpd
Module for handling Macrostate Probability Distribution (MPD) data.
MPD
MPD(
dataframe: DataFrame,
temperature: float,
beta_mu: Optional[float] = None,
fugacity: Optional[float] = None,
metadata: Optional[dict[str, Any]] = None,
order: int = 50,
tolerance: float = 10.0,
)
Class for storing and processing macrostate probability distribution.
Parameters:
-
dataframe(DataFrame) –a pandas dataframe with state specific data
-
temperature(float) –temperature (in K) at which the simulation was performed
-
beta_mu(Optional[float], default:None) –beta_mu (unitless) at which the simulation was performed. At least one of beta_mu or fugacity must be specified
-
fugacity(Optional[float], default:None) –fugacity (in Pa) at which the simulation was performed. At least one of beta_mu or fugacity must be specified
-
metadata(Optional[dict[str, Any]], default:None) –a dictionary with the simulation metadata
-
order(int, default:50) –how many points on each side use to find minimum in lnp
-
tolerance(float, default:10.0) –used when checking the probability at lnp tail
Source code in src/asaf/mpd.py
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 | |
lnp
property
lnp: DataFrame
Return a dataframe with the natural logarithm of the macrostate probability.
tolerance
property
writable
tolerance: float
Return the tolerance used when checking the probability at lnp tail.
average_macrostate
Calculate the average macrostate from the MPD data.
Note that this function does not check for multiple phases. Use average_macrostate_at_fugacity
to calculate the average macrostate at a given fugacity, which checks for multiple phases.
Source code in src/asaf/mpd.py
337 338 339 340 341 342 343 344 345 | |
average_macrostate_at_fugacity
Calculate the average macrostate at a given fugacity.
Source code in src/asaf/mpd.py
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 | |
calculate_isotherm
calculate_isotherm(
fugacity: ArrayLike,
saturation_fugacity: Optional[float] = None,
pressure: Optional[ArrayLike] = None,
order: Optional[int] = None,
return_dataframe: bool = True,
) -> Union[DataFrame | Isotherm]
Calculate the adsorption isotherm.
Parameters:
-
fugacity(ArrayLike) –Array of fugacities.
-
saturation_fugacity(Optional[float], default:None) –Saturation pressure to calculate the pressure in relative scale (p/p0).
-
pressure(Optional[ArrayLike], default:None) –Array of pressures corresponding to the fugacities.
-
order(Optional[int], default:None) –How many points on each side use to find minimum in lnp.
-
return_dataframe(bool, default:True) –Whether to return the adsorption isotherm as a dataframe or Isotherm instance.
Returns:
-
DataFrame or Isotherm–DataFrame containing the adsorption isotherm or Isotherm instance if return_dataframe is False.
-
Args(Union[DataFrame | Isotherm]) –pressure:
Source code in src/asaf/mpd.py
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 | |
check_tail
Check the probability at the tail of the lnp distribution.
Source code in src/asaf/mpd.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
dataframe
dataframe() -> DataFrame
Return dataframe.
Source code in src/asaf/mpd.py
137 138 139 | |
extrapolate
extrapolate(
temperature: float,
energy: Optional[DataFrame | Series] = None,
terms: int = 1,
) -> "MPD"
Extrapolates the MPD to a new temperature.
Parameters:
-
temperature(float) –Temperature (in K) to which to extrapolate MPD.
-
energy(Optional[DataFrame | Series], default:None) –Energy fluctuation data. If None ASAF will look for data in prob_df. Unit must be J.
-
terms(int, default:1) –Number of Taylor series terms used for extrapolation. Note that
energymust contain columns namedterm_1,term_2, ...,term_nwhere n is the number of terms.
Returns:
-
MPD–Extrapolated MPD.
Source code in src/asaf/mpd.py
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 | |
find_phase_equilibrium
find_phase_equilibrium(
tolerance: float = 1e-06,
max_iterations: int = 100,
return_probabilities: bool = False,
) -> Union[Tuple[float, float, float], float]
Find the fugacity at which the two phases are in equilibrium.
Parameters:
-
tolerance(float, default:1e-06) –Tolerance for the root finding algorithm.
-
max_iterations(int, default:100) –Maximum number of iterations for the root finding algorithm.
-
return_probabilities(bool, default:False) –Whether to return the probabilities of the two phases at equilibrium.
Returns:
-
float or Tuple[float, float, float]–The fugacity at which the two phases are in equilibrium. If
return_probabilitiesis True, also returns the probabilities of the two phases at equilibrium.
Source code in src/asaf/mpd.py
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 324 325 326 327 328 329 330 331 332 333 334 335 | |
free_energy_at_fugacity
free_energy_at_fugacity(fug: float) -> DataFrame
Calculate the free energy profile at a given fugacity.
Source code in src/asaf/mpd.py
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | |
from_csv
classmethod
Read natural logarithm of macrostates probability or transition probabilities from a csv file.
Source code in src/asaf/mpd.py
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 | |
minimums
Find the local minimums in the lnp data.
Source code in src/asaf/mpd.py
347 348 349 350 351 352 353 354 | |
plot
Plot the MPD data using plotly.
Source code in src/asaf/mpd.py
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 | |
reweight
reweight(delta_beta_mu: float) -> DataFrame
Reweight the MPD to a new mu / fugacity value using delta_beta_mu.
Source code in src/asaf/mpd.py
252 253 254 255 256 257 258 259 | |
reweight_to_fug
Reweight the MPD to a new mu / fugacity value using desired fugacity.
Source code in src/asaf/mpd.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | |
options: filters: ["!^_"]