User:Jacob

From ASCEND
Jump to navigation Jump to search


Jacob Shealy is a student in the Computer Programming Certificate track at J. Sargeant Reynolds Community College in Richmond, Virginia. He also has a B.S. in Chemical Engineering from the University of Virginia.

Project Overview

This project is intended to add the ability to model ideal-solution mixing in FPROPS. Specifically, I will add functions that may be used to define mixtures of several pure components, and obtain their ideal-solution properties.

Ideal solutions make heavy use of pure-component properties, thus this project will build directly on existing FPROPS features. Non-ideal ('real') solution properties are commonly found from ideal solution properties plus 'excess' properties, so any future implementation of non-ideal solutions will presumably use these ideal-solution functions as a foundation.

I expect to implement functions to find:

  • The following properties, given T and rho (temperature and solution mass density) plus the mixture components:
    • P (pressure),
    • cp (constant-pressure heat capacity),
    • cv (constant-volume heat capacity),
    • u (internal energy),
    • h (enthalpy),
    • s (entropy),
    • g (Gibbs energy),
    • a (Helmholtz energy)
  • Mixing conditions (T, and P or rho) for a mixture with components that start at different conditions.

If time permits, I plan to lay the groundwork for non-ideal solutions. This would involve writing general functions to find partial molar properties (PMPs) for the properties above. It would also mean implementing functions which had the same inputs as would be used for non-ideal solutions, but with only ideal-solution models available for now. That is, excess properties would always be set to zero for now.

Schedule for GSOC 2015

This schedule represents current expectations as of June 1. Throughout the summer, I may be revising this schedule, adding edits in italics, with the date of each edit.

Week of May 25

  • Review theory and resolve any remaining questions about thermodynamic equations to be implemented; specify exact form of equations.
  • Explore in detail how pure-component properties are implemented in FPROPS, with attention to any issues that arise from theory.
  • Study existing ASCEND and C API of FPROPS further, to gain a better idea of how API to ideal-solution functions will have to work.

Week of June 1

  • Implement simple ad-hoc mixing model as a test of theory and to determine what data and procedures are necessary.
  • Based on theory and the findings from ad-hoc model, begin to specify data structures to be used for defining mixtures, storing mixture state, and performing ideal solution calculations.
  • Determine what pre-existing pure-component data structures will have to be passed in to the functions.

Week of June 8

  • Continue to determine necessary data structures and procedures for general ideal-solutions case. This may include specialized root-finding procedures for finding mixing conditions.
  • Provisionally specify form and purpose of functions in final API of solutions model.

Week of June 15

  • Write required new data structures for mixture definition and description.
  • Finalize special procedures (e.g. root-finding functions) for solutions model
  • Continue to plan function input and output for API. Write function(s) for defining mixtures from pure components.

Week of June 22

  • Write preliminary forms of functions for first-law properties (P, rho, u, h, cp, cv &mdash) for mixtures. These properties are described by the first law of thermodynamics, hence the name.
  • Preliminary unit testing of these functions, especially in integration with functions for defining mixtures.

Week of June 29

  • Continue testing of first-law mixture property functions
  • Finalize integration of property and mixture-definition functions into final API.
  • Mid-term occurs at the end of this week, so one reasonable criterion for the mid-term evaluation would seem to be completion of first-law mixture property functions.

Week of July 6

  • Review progress to-date, and perform any catch-up. This week has no specifically assigned work.
  • I am planning to be on vacation from Tuesday of this week through Friday of the next week; hence the week of the 13th also has a light work load.

Week of July 13

  • Write preliminary forms of property functions for second-law properties (s, g, a). This should be closely analogous to the first-law property functions.
  • Perform preliminary unit testing of second-law property functions.

Week of July 20

  • Continue testing and integrating second-law property functions Review thermodynamics of partial molar properties (PMPs) and chemical potential. Chemical potential and related properties such as fugacity are used intensively in non-ideal solution modeling, and I want to provide functions for handling these quantities explicitly.
  • Review thermodynamics of non-ideal solutions, to try to determine what structures may be needed to handle such solutions.
    • The goal here is to successfully implement ideal-solution property functions in a form that can be cleanly extended to non-ideal-solution models.
    • To implement non-ideal models, we would simply add the logic to calculate excess properties.
  • Most work after this point is not strictly necessary to implement ideal-solution modeling, but rather is in preparation for extending the solution model to non-ideal systems.

Week of July 27

  • Specify exact form of equations for solution properties in terms of chemical potential.
  • Determine any special mixing conditions that may exist for non-ideal solutions. (There should not be any, but I want to check. The functions for finding mixing conditions for ideal solutions should be sufficient.)
  • Specify form of general-purpose solution property functions that for now only calculate ideal-solution properties.
  • Specify data structures to use in general-purpose solution property functions, and begin writing forms that these data structures will take for the simple case of ideal solutions.

Week of August 3

  • Review progress, and perform any further catch-up work, if such is needed.
  • This will probably be another relatively light week, and I plan to be at the beach for most of it.
  • Write preliminary form of functions for chemical potential and PMPs, as may be used by general-purpose mixture-property functions (but only returning the trivial ideal-solution values for now).
  • Preliminary unit testing of chemical potential and partial molar property functions.

Week of August 10

  • Continue to write and test chemical potential/PMP functions
  • Write preliminary form of general-purpose solution-property functions (in P,rho,u,h,cp,cv,s,g,a)
    • For now, these may simply call the ideal-solution property functions created earlier, but they must implement logic for choosing the ideal solution case.

August 17

  • Final testing of whole ideal-solution system.
  • Perform any final revision of chemical potential, PMP, and general-purpose property functions.
  • If time remains, plan out and write recommendations on how fluid-property files (e.g. acetone.c) may need to be extended for


Weekly/Daily Progress Report

Week of May 25

May 25, 26, 27:

Reviewed thermodynamic theory, determining the form of equations describing ideal solutions in terms of mass rather than moles, and specification of how mixing conditions may be calculated

May 27, 28, 29:

Examined existing FPROPS code further in light of thermodynamics. The 'sat', 'solve_ph', 'solve_px', and 'solve_Tx' files implement functions that solve iteratively for T,rho, or both in terms of other properties; this is similar to what the 'mixture_prepare' function will have to do to find reasonable solution conditions. Determined how FPROPS implements this functionality, using e.g. zeroin.c

Reviewed files in /fprops/test directory to familiarize myself with the C API of FPROPS. Started writing some peripheral functions for easier construction of similar test files.

Week of June 1

June 1:

Branch ASCEND repository and check out /models/johnpye/fprops directory to my working directory (removing the check out of /models/johnpye/fprops from the trunk that I was using before)

Write up this wiki page, and start to write up results of my studies from last week for the Explainations section below.

Start to write an initial ad-hoc model of three-phase mixing, to test procedures and theory.

Explainations and Analysis

This section is intended to contain explainations and conclusions on specific issues that arise while studying the relevant thermodynamics, etc.

Mass-Specific Version of Ideal-Solution Equations

Throughout FPROPS, most pure-component properties are specific in mass - for instance, enthalpy is calculated not in absolute terms but per-unit-mass, in units of J/kg. On the other hand, most textbook discussions of solution thermodynamics seem to assume a mole basis, e.g. enthalpy is calculated in units of J/mol. To use the existing FPROPS functions most effectively, I have to determine how expressions for solution properties in terms of moles convert into expressions in terms of mass.

I have an extensive discussion of solution thermodynamics at http://www.jacobsworkbench.com/ascend/thermo.php ; the most important equations, expressed in terms of moles are at http://www.jacobsworkbench.com/ascend/thermo.php#is_properties .

In general, the molar form of ideal-solution equations look generally like

([[#equation_{{{3}}}|{{{3}}}]])
1

for first-law ideal-solution properties (v, u, h, cp, cv). Here <math>u^{is}</math> is the ideal-solution internal energy.

Using the molar mass M, we can find the mass fraction for component i, <math>X_i</math> from the mole fraction <math>x_i</math>, and derive the other expressions for first-law and second-law properties in solution. The use of primes indicates mass-specific as opposed to mole-specific properties

([[#equation_{{{3}}}|{{{3}}}]])
{{{2}}} </math>|2}}
([[#equation_{{{3}}}|{{{3}}}]])
3
([[#equation_{{{3}}}|{{{3}}}]])
4
([[#equation_{{{3}}}|{{{3}}}]])
5
([[#equation_{{{3}}}|{{{3}}}]])
([[#equation_|]])
<math> </math>

Mixing Conditions

Ideal-solution mixing occurs