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
  My code works on Jupyter Lab/Notebook, but NOT on Visual Code Editor jst 4 1,050 Nov-15-2023, 06:56 PM
Last Post: jst
  Navigating file directories and paths inside Jupyter Notebook Mark17 5 718 Oct-29-2023, 12:40 PM
Last Post: Mark17
  Likert survey data plot error Andrzej_Andrzej 6 1,438 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 858 May-29-2023, 02:42 PM
Last Post: Nietzsche
  How to programmatically stop a program in Jupyter Notebook? Mark17 11 37,248 Feb-12-2023, 01:41 PM
Last Post: jp21in
  Create simple live plot of stock data dram 2 2,936 Jan-27-2023, 04:34 AM
Last Post: CucumberNox
  Graphs from Jupyter notebook to word Scott 0 890 Nov-28-2022, 06:16 AM
Last Post: Scott
  Opening an empty Jupyter notebook in VSCODE Krischu 3 1,860 Mar-09-2022, 01:57 PM
Last Post: Larz60+
  Help Python vs Jupyter futureofAI 2 1,588 Oct-17-2021, 09:45 AM
Last Post: futureofAI
  How to do line continuation in Jupyter Notebook? Mark17 4 5,521 Sep-22-2021, 04:22 PM
Last Post: ibreeden

Forum Jump:

User Panel Messages

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