ORNL-CEES / thermochimica

Computational library for chemical thermodynamics and phase equilibrium calculation. Multiphysics and standalone estimations of chemical state and constitutive and transport properties.
BSD 3-Clause "New" or "Revised" License
43 stars 25 forks source link

Pseudo Binary Phase Diagram: Incompatible Dimensions for Cross Product #152

Closed mlouis9 closed 6 months ago

mlouis9 commented 6 months ago

Describe the bug When attempting to compute a pseudo binary phase diagram for a molten salt system (using the MSTDB-TC 3.0 here), the following error is produced when trying to plot the phase diagram:

  File "/home/mlouis9/thermochimica/python/pseudoBinaryPhaseDiagramGUI.py", line 595, in <module>
    window.read()
  File "/home/mlouis9/thermochimica/python/pseudoBinaryPhaseDiagramGUI.py", line 150, in read
    self.calculation.processPhaseDiagramData()
  File "/home/mlouis9/thermochimica/python/pseudoBinaryPhaseDiagramFunctions.py", line 127, in processPhaseDiagramData
    crossNorms = [np.linalg.norm(np.cross(phaseCompositions[k] - self.plane[0],self.plane[1] - phaseCompositions[k])) for k in range(nPhases)]
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mlouis9/thermochimica/python/pseudoBinaryPhaseDiagramFunctions.py", line 127, in <listcomp>
    crossNorms = [np.linalg.norm(np.cross(phaseCompositions[k] - self.plane[0],self.plane[1] - phaseCompositions[k])) for k in range(nPhases)]
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mlouis9/miniconda3/lib/python3.11/site-packages/numpy/core/numeric.py", line 1596, in cross
    raise ValueError(msg)
ValueError: incompatible dimensions for cross product
(dimension must be 2 or 3)

To calculate the solubility of $\text{PuCl}_3$ in the eutectic salt $\text{LiCl - KCl - PuCl}_3$ ( $0.586(1-x)$ - $0.414(1-x)$ - $x$) where $x$ is the mole fraction of $\text{PuCl}_3$ and the $\text{LiCl-KCl}$ ratio is kept fixed at the (eutectic) ratio $0.586:0.414$ I would like to construct a pseudo binary phase diagram with one endmember as $\text{LiC - KCl}$ ($0.586$ - $0.414$) and the other as $\text{PuCl}_3$.

To Reproduce Run the script thermochimica/scripts/pseudoBinaryPhaseDiagramGUI.sh select the datafile MSTDB-TC_V3.0_Chlorides_No_Functions_8-2.dat (available from the MSTDB-TC gitlab here. Input the following parameters

Input The desired input should be automatically generated using the GUI

Expected behavior I'd expect a phase diagram plot to appear, which does indeed happen for pseudobinary systems such as $\text{LiCl - KCl}$ and $\text{LiCl - PuCl}_3$, so the issue in this case seems to be having a four dimensional plane (i.e. involving 4 elements rather than 3). I should note that the thermochimica calculation executes correctly, and seems to produce valid output, but it errors when the postprocessing routines are called for creating the plot.

Screenshots The issue is adequately captured in the error message.

System (please complete the following information):

Commit:

mlouis9 commented 6 months ago

This type of calculation is not currently supported by the Thermochimica pseudoBinaryPhaseDiagramGUI script, but can be executed using standalone calculations. This was resolved by meeting with @markuspiro on Teams.