René's URL Explorer Experiment


Title: ePCSAFT example · feos-org/feos · Discussion #270 · GitHub

Open Graph Title: ePCSAFT example · feos-org/feos · Discussion #270

X Title: ePCSAFT example · feos-org/feos · Discussion #270

Description: ePCSAFT example

Open Graph Description: Hello everyone, First of all I want to thank you for providing this amazing eos package! Currently, I try to model gas solubilities in aqueous solutions. Recently your group published this paper ht...

X Description: Hello everyone, First of all I want to thank you for providing this amazing eos package! Currently, I try to model gas solubilities in aqueous solutions. Recently your group published this paper ht...

Opengraph URL: https://github.com/feos-org/feos/discussions/270

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"ePCSAFT example","text":"

Hello everyone,

\n

First of all I want to thank you for providing this amazing eos package!
\nCurrently, I try to model gas solubilities in aqueous solutions. Recently your group published this paper https://pubs.acs.org/doi/10.1021/acs.jced.4c00347, where you extended and use the ePCSAFT model and refer to feos.
\nDo you have a minimal example of how to use the ePCSAFT in feos?

\n

Thanks and best regards,

\n

Sven

","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"

Hi Sven,

\n

here is an example for MIAC of NaCl (modeled as two components) in water. The paths used assume that you work inside the \"examples\" folder. I cut it into three parts.

\n

1. Imports and helper functions

\n

Imports for FeOs, SI units and plotting and helper functions to calculate the mean ionic activity coefficient:

\n
from feos.eos import *\nfrom feos.epcsaft import *\nimport si_units as si\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nsns.set_context('notebook')\nsns.set_palette('Dark2')\nsns.set_style('ticks')\n\ndef molality_to_mole_fraction(\n    molality_solute: si.SIObject, \n    molarweight_solvent: si.SIObject\n) -> float:\n    \"\"\"Calculate mole fraction of solute from solute molality given molar weight of solvent.\n\n    Args:\n        molality_solute: Molality of solute (salt).\n        molarweight_solvent: Molar weight of solvent.\n\n    Returns:\n        Mole fraction of solute (salt)\n    \"\"\"\n    return molality_solute * molarweight_solvent / (1.0 + molality_solute * molarweight_solvent)\n\ndef mean_ionic_activity_coefficient(\n    eos: EquationOfState,\n    temperature: si.SIObject, \n    pressure: si.SIObject, \n    molality_solute: si.SIObject,\n    molarweight_solvent: si.SIObject,\n    stoichiometric_coefficients: np.ndarray\n) -> float:\n    \"\"\"Calculate mean ionic activity coefficient (MIAC). \n\n    1. calculates fugacity coefficients for given molality and inf. dilution\n    2. uses eq. 9 to calculate activity coefficients from fugacities\n    3. uses eq. 8 to get MIAC\n    \n    Args:\n        eos: Equation of state to use\n        temperature: Temperature\n        pressure: Pressure\n        molality_solute: Molality of solute (salt).\n        molarweight_solvent: Molar weight of solvent.\n        stoichiometric_coefficients: \n            Stoichiometric coefficients of salt ions.\n            Order has to match parameter order.\n\n    Returns:\n        Mean ionic activity coefficient.\n    \"\"\"\n    # mole fraction of salt from molality\n    x_ions = molality_to_mole_fraction(molality_solute=molality_solute, molarweight_solvent=molarweight_solvent)\n    # mole fractions from closure\n    molefracs = np.array([1 - x_ions, x_ions / 2, x_ions / 2])\n\n    # thermodynamic condition\n    state = State(eos, temperature=temperature, pressure=pressure, molefracs=molefracs)\n    # reference: infinite dilution (same for each ion so only calculated once)\n    infinite_dilution = State(eos, temperature=temperature, pressure=pressure, molefracs=np.array([1.0, 0.0, 0.0]))\n\n    # Equation 9\n    # only use ion activity coefficients (component 0 is solvent)\n    ac_ions = (np.exp(state.ln_phi()) / np.exp(infinite_dilution.ln_phi()))[1:]\n    # Equation 8\n    miac = np.prod(ac_ions**stoichiometric_coefficients)**(1 / stoichiometric_coefficients.sum())\n    return miac
\n

2. Initializing the substances, equation of state and thermodynamic conditions

\n

For this example and the above functions, we assume that the solvent is always component at index 0 and the two ions are 1 and 2.
\nIf you initialize your substances in a different order, you have to adjust the code accordingly.

\n
# parameters\nparameters = ElectrolytePcSaftParameters.from_json(\n    substances=['water', 'sodium ion', 'chloride ion'],\n    pure_path='../parameters/epcsaft/held2014_w_permittivity_added.json',\n    binary_path='../parameters/epcsaft/held2014_binary.json'\n)\nmolarweight_water = parameters.pure_records[0].molarweight * si.GRAM / si.MOL\n\n# equation of state\neos = EquationOfState.epcsaft(parameters, epcsaft_variant=ElectrolytePcSaftVariants.Advanced)\n\n# thermodynamic conditions\ntemperature = 298.15 * si.KELVIN\npressure = si.BAR\n# stoichiometric coefficients for [Na+] and [Cl-]\nnu = np.array([1.0, 1.0])
\n

3. Calculating the MIAC's and plotting the results

\n
# mean ionic activity coefficients\nmolality_salt = si.linspace(0 * si.MOL / si.KILOGRAM, 6.0 * si.MOL / si.KILOGRAM, 100) \ngammas = np.array([\n    mean_ionic_activity_coefficient(eos, temperature, pressure, b, molarweight_solvent=molarweight_water, stoichiometric_coefficients=nu) \n    for b in molality_salt\n])\n\n# plot results\nplt.plot(molality_salt / si.MOL * si.KILOGRAM, gammas, clip_on=False)\nplt.xlabel(r'Molality $m_\\text{salt}$ / mol / kg')\nplt.ylabel(r'$\\gamma^{*, x}_\\pm$')\nplt.xlim(0, 6)\nplt.ylim(0.7, 1.2)\nsns.despine(offset=10);
\n

I hope that helps - let us know if there are any more questions.

","upvoteCount":1,"url":"https://github.com/feos-org/feos/discussions/270#discussioncomment-12083231"}}}

route-pattern/_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format)
route-controllervoltron_discussions_fragments
route-actiondiscussion_layout
fetch-noncev2:1b5d5578-dc7a-e9cb-1993-69995c518d35
current-catalog-service-hash9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be
request-id99BC:8EA1A:5AAD09:7B32D6:698F666D
html-safe-nonce5feac99cc9386431d8147ff33e259953657ad097f8960dc2a3f548ea3cfe666b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OUJDOjhFQTFBOjVBQUQwOTo3QjMyRDY6Njk4RjY2NkQiLCJ2aXNpdG9yX2lkIjoiMzM3ODI1NDc3ODEwMjQwODgxMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac8831389c7a9c026c880176f40f6c47aa65704c657e8c5a125d38c47ce8ff06fb
hovercard-subject-tagdiscussion:7920986
github-keyboard-shortcutsrepository,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/discussions_fragments/discussion_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/feos-org/feos/270/discussion_layout
twitter:imagehttps://opengraph.githubassets.com/60c0b2271e6f8e89e49024c64da86f0d68b4c7726f238288507303e6ea5a4a5e/feos-org/feos/discussions/270
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/60c0b2271e6f8e89e49024c64da86f0d68b4c7726f238288507303e6ea5a4a5e/feos-org/feos/discussions/270
og:image:altHello everyone, First of all I want to thank you for providing this amazing eos package! Currently, I try to model gas solubilities in aqueous solutions. Recently your group published this paper ht...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None7ab1c9acb90dba91d5e994ebfb6bfb1130e0e0e6aca329cdbbd934d636e22ab6
turbo-cache-controlno-preview
go-importgithub.com/feos-org/feos git https://github.com/feos-org/feos.git
octolytics-dimension-user_id87855701
octolytics-dimension-user_loginfeos-org
octolytics-dimension-repository_id424905104
octolytics-dimension-repository_nwofeos-org/feos
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id424905104
octolytics-dimension-repository_network_root_nwofeos-org/feos
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release04a785903b8c8db66e4594aee5b2e56cf7232706
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/feos-org/feos/discussions/270#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Ffeos-org%2Ffeos%2Fdiscussions%2F270
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Ffeos-org%2Ffeos%2Fdiscussions%2F270
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fdiscussions_fragments%2Fdiscussion_layout&source=header-repo&source_repo=feos-org%2Ffeos
Reloadhttps://patch-diff.githubusercontent.com/feos-org/feos/discussions/270
Reloadhttps://patch-diff.githubusercontent.com/feos-org/feos/discussions/270
Reloadhttps://patch-diff.githubusercontent.com/feos-org/feos/discussions/270
feos-org https://patch-diff.githubusercontent.com/feos-org
feoshttps://patch-diff.githubusercontent.com/feos-org/feos
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Ffeos-org%2Ffeos
Fork 30 https://patch-diff.githubusercontent.com/login?return_to=%2Ffeos-org%2Ffeos
Star 177 https://patch-diff.githubusercontent.com/login?return_to=%2Ffeos-org%2Ffeos
Code https://patch-diff.githubusercontent.com/feos-org/feos
Issues 22 https://patch-diff.githubusercontent.com/feos-org/feos/issues
Pull requests 6 https://patch-diff.githubusercontent.com/feos-org/feos/pulls
Discussions https://patch-diff.githubusercontent.com/feos-org/feos/discussions
Actions https://patch-diff.githubusercontent.com/feos-org/feos/actions
Projects 0 https://patch-diff.githubusercontent.com/feos-org/feos/projects
Security 0 https://patch-diff.githubusercontent.com/feos-org/feos/security
Insights https://patch-diff.githubusercontent.com/feos-org/feos/pulse
Code https://patch-diff.githubusercontent.com/feos-org/feos
Issues https://patch-diff.githubusercontent.com/feos-org/feos/issues
Pull requests https://patch-diff.githubusercontent.com/feos-org/feos/pulls
Discussions https://patch-diff.githubusercontent.com/feos-org/feos/discussions
Actions https://patch-diff.githubusercontent.com/feos-org/feos/actions
Projects https://patch-diff.githubusercontent.com/feos-org/feos/projects
Security https://patch-diff.githubusercontent.com/feos-org/feos/security
Insights https://patch-diff.githubusercontent.com/feos-org/feos/pulse
Answered https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270#discussioncomment-12083231
g-bauerhttps://patch-diff.githubusercontent.com/g-bauer
svenpohl1991 https://patch-diff.githubusercontent.com/svenpohl1991
Q&Ahttps://patch-diff.githubusercontent.com/feos-org/feos/discussions/categories/q-a
ePCSAFT example https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270#top
svenpohl1991 https://patch-diff.githubusercontent.com/svenpohl1991
Answered https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270#discussioncomment-12083231
g-bauerhttps://patch-diff.githubusercontent.com/g-bauer
Return to tophttps://patch-diff.githubusercontent.com/feos-org/feos/discussions/270#top
Please reload this pagehttps://patch-diff.githubusercontent.com/feos-org/feos/discussions/270
https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270
Please reload this pagehttps://patch-diff.githubusercontent.com/feos-org/feos/discussions/270
https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270
svenpohl1991 https://patch-diff.githubusercontent.com/svenpohl1991
Feb 5, 2025 https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270#discussion-7920986
https://pubs.acs.org/doi/10.1021/acs.jced.4c00347https://pubs.acs.org/doi/10.1021/acs.jced.4c00347
Give feedback.https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270
g-bauer https://patch-diff.githubusercontent.com/g-bauer
Feb 6, 2025 https://github.com/feos-org/feos/discussions/270#discussioncomment-12083231
View full answer https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270#discussioncomment-12083231
Oldest https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270?sort=old
Newest https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270?sort=new
Top https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270?sort=top
Please reload this pagehttps://patch-diff.githubusercontent.com/feos-org/feos/discussions/270
https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270
Please reload this pagehttps://patch-diff.githubusercontent.com/feos-org/feos/discussions/270
https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270
g-bauer https://patch-diff.githubusercontent.com/g-bauer
Feb 6, 2025 https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270#discussioncomment-12083231
Give feedback.https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270
svenpohl1991https://patch-diff.githubusercontent.com/svenpohl1991
Sign up for freehttps://patch-diff.githubusercontent.com/join?source=comment-repo
Sign in to commenthttps://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Ffeos-org%2Ffeos%2Fdiscussions%2F270
🙏 Q&A https://patch-diff.githubusercontent.com/feos-org/feos/discussions/categories/q-a
https://patch-diff.githubusercontent.com/svenpohl1991
https://patch-diff.githubusercontent.com/g-bauer
https://patch-diff.githubusercontent.com/feos-org/feos/discussions/270
https://patch-diff.githubusercontent.com/settings/replies?return_to=1
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.