Python Forum
Python 3 Jupyter notebook ternary plot data
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python 3 Jupyter notebook ternary plot data
#1
Thumbs Up 
I'm using the ternary library and Matplotlib to plot a heat map of gibbs free energy of mixing and a thermodynamic phase diagram for a ternary solution of drug, polymer and water across a range of ~5000 composition combinations.

Currently my code can generate these 2 plots by solving the Flory-Huggins equation for the ternary system in question, but the solutions are calculated and plotted in terms of volume fraction of each component in the system. I wish to convert the respective volume fractions to mole fractions and plot this data in the ternary diagram instead.

The format of the data used by ternary to generate the heat map is a string as follows, with the VOLUME fractions highlighted in purple (3 values inside parentheses):

{(1.0, 1.0, 98.0): 0.019617699619267185, (1.0, 2.0, 97.0): 0.012496629067697308, (1.0, 3.0, 96.0): 0.0054235597962929635, (1.0, 4.0, 95.0): -0.0016045949027236467...

To convert each volume fraction to mole fraction, I would need to perform a simple equation on each of these vol. fraction values inside the brackets
e.g.

mole fraction of drug nD = vD*rhoD/mrD/(vD*rhoD/mrD+vP*rhoP/mrP+vW*rhoW/mrW)

D = drug, P = polymer, W = water, nD = mole fraction of drug, vX = volume fraction of component, rho = density, mr = molar mass.

Is there a simple way to carryout this operation systematically across all volume fraction data points. I was thinking if I could convert this string into a dataframe it would be easier to target each component value but there are many colons, parentheses, commas etc in the data string of values so can this string even be parsed effectively? Also there is then the issue of converting it back to the appropriate format I assume?

Hope this makes sense

Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I'm trying to import a dataset into a Jupyter Notebook Hisilat03 0 700 Mar-24-2025, 09:26 AM
Last Post: Hisilat03
  Jupyter Notebook cell ? flaviu2 6 4,871 Feb-10-2025, 09:39 AM
Last Post: mysqlguider
  import data (.csv) into Jupyter notebook oranstprotonme 2 1,153 Aug-14-2024, 07:08 PM
Last Post: oranstprotonme
  Troubleshooting Jupyter Notebook installation with Python using pip and a venv Drone4four 1 2,009 Jun-04-2024, 10:55 PM
Last Post: Drone4four
  Install python 2.7 in jupyter lab raman 28 5,027 Jun-01-2024, 01:53 PM
Last Post: snippsat
  My code works on Jupyter Lab/Notebook, but NOT on Visual Code Editor jst 4 4,105 Nov-15-2023, 06:56 PM
Last Post: jst
  Navigating file directories and paths inside Jupyter Notebook Mark17 5 7,789 Oct-29-2023, 12:40 PM
Last Post: Mark17
  Likert survey data plot error Andrzej_Andrzej 6 3,189 Jul-16-2023, 10:11 PM
Last Post: deanhystad
  Plot a pandas data fram via pyqtgraph with an modul import and qt designer widget Nietzsche 0 1,488 May-29-2023, 02:42 PM
Last Post: Nietzsche
  How to programmatically stop a program in Jupyter Notebook? Mark17 11 58,900 Feb-12-2023, 01:41 PM
Last Post: jp21in

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020