Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Workspace API #432

Open
wants to merge 170 commits into
base: develop
Choose a base branch
from
Open

Conversation

richardotis
Copy link
Collaborator

@richardotis richardotis commented Oct 23, 2022

  • Adds a new Workspace object and associated imperative API. This object now underlies the equilibrium function, which remains for backwards compatibility. A Workspace object can be mutated after creation. The Workspace.get() function accepts ComputableProperty objects as input and returns arrays; the Workspace.plot() function works similarly, but returns a matplotlib figure. Fixes Develop a wrapper API for plotting properties from calculate and equilibrium #154
  • Adds a new PhaseRecordFactory object and associated connections to PhaseRecord, which enables deferred compilation of symbolically-defined model properties until they are called in the PhaseRecord API. The PhaseRecord object also gains prop and prop_grad functions for computing properties and property gradients of arbitrary symbolic attributes of Model instances.
  • Creates a "Computable Property Framework" (CPF) for calculating properties of the system, individual phases, or some combination of these. It also provides a framework for defining custom properties.
  • Adds support for "dot" derivatives (constrained total derivatives) of thermodynamic properties (fixes Heat capacities calculated by Model can sometimes be incorrect #261 )
  • Adds support for T0 (tzero) calculation
  • Adds support for driving force calculation, including nucleation driving forces, via the IsolatedPhase and DormantPhase meta-properties. Meta-properties are objects that know how to create new properties (as defined by the CPF). In this case, these meta-properties know how to start sub-calculations . The current way of finding starting points for these calculations is not ideal and prone to failure (basically reuses CompositionSet objects from the workspace equilibrium calculation), but it works well in the typical case.
  • Adds physical units support via pint. All ComputableProperty objects have "implementation units" and "display units." Implementation units are what are assumed by the underlying numerical computation (which is done without units, for performance). The display units are what the user gets when Workspace.get or Workspace.plot are called. ComputableProperty.__getitem__ allows the display units to be changed for individual calls to Workspace.get, Workspace.plot, or when setting Workspace.conditions.
  • Also regarding physical units, a special unit conversion context is defined to allow conversions between per-mole properties and per-mass properties. There's room to add per-volume here as well, but that may not make it into this PR.
  • Adds support for specifying linear combinations and ratios of mole fractions as a condition.
  • Adds support for specifying weight fractions as a condition.
  • Associated tests for these new features.

Documentation

  • Adds several examples for the Computable Property API, including driving force, T0, and isolated energy surfaces. A demo of export-to-DataFrame is also shown using the new PandasRenderer.
  • Other examples have been updated to use the new APIs. Examples using the legacy APIs continue to be supported, but have been moved to a new "Advanced Examples" section. These sections will continue to be expanded and reorganized to accommodate our evolving best practices.
  • If any dependencies have changed, the changes are reflected in the
    • setup.py (runtime requirements)

richardotis and others added 30 commits June 13, 2022 18:32
@sorkins
Copy link

sorkins commented Nov 30, 2023

Here's the link to my fork where I made the changes, which might help more: https://github.com/sorkins/richardotis-pycalphad/tree/dot_derivatives_ss

richardotis referenced this pull request in sorkins/richardotis-pycalphad Dec 29, 2023
@bocklund
Copy link
Collaborator

bocklund commented Feb 8, 2024

I'm just starting to use this a bit, I'm wondering if I missed if there's a hook to give units for ModelComputedProperty that are not derived from the energy. Specifically, I've been looking at VM, V0, etc

@richardotis
Copy link
Collaborator Author

I'm just starting to use this a bit, I'm wondering if I missed if there's a hook to give units for ModelComputedProperty that are not derived from the energy. Specifically, I've been looking at VM, V0, etc

The way it works at the moment is somewhat hacky. You can assign a variable to this module: https://github.com/richardotis/pycalphad/blob/a0541fe69317348d0627ab72440b00c84a3891a0/pycalphad/property_framework/units.py#L22-L36

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Path to 1.0
In progress
3 participants