Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mixing Metals with Snakes - Moving an Industry Forward by Johan Zietsman

Pycon ZA
October 06, 2017

Mixing Metals with Snakes - Moving an Industry Forward by Johan Zietsman

The South Africa mining and metallurgical industry is the bedrock of our economy... or it is supposed to be. We are blessed with more mineral resources than any other country in the world. Unfortunately we are tending, more and more, to export ore to China and other countries without adding value to it here. The end result is that we lose billions of Rand in potential revenue.

Computational modelling plays an important part in helping us understand things better, make better decisions, develop better processes, and be more competitive. In our metallurgical industry processes are mostly described with Excel models. These models have many drawbacks, and of limited use. There is another way. We can integrate detailed thermochemistry into our models to describe process more accurately. This, however, is fairly difficult, and not many people are able to do it. Our challenge is to make this type of modelling easier, and to make it more accessible, so that our industry can benefit.

Our journey has been a long one, and has winded through territories like C++, VB, VBA, C#.net and others. Eventually we arrived at Python. We will share our experiences in using things like Django, Jinja2, Celery and Postgres to move modelling of metallurgical processes into the 21st century, into the cloud, and to move our industry forward.

Pycon ZA

October 06, 2017
Tweet

More Decks by Pycon ZA

Other Decks in Programming

Transcript

  1. PyConZA 2017 1 Mixing Metals with Snakes Moving an Industry

    Forward Johan Zietsman 6 October 2017 PyConZA 2017 + = ΔG
  2. PyConZA 2017 2 Purpose Demonstrate how Python is used as

    part of software developed to – improve our understanding of complex high- temperature processes; – develop new process technologies. Get some feedback and ideas.
  3. PyConZA 2017 3 Content • South African economy • South

    African mining and metals industry • Ex Mente • Thermochemistry • Modelling and simulation software – History – Current status – Future plans • Conclusion
  4. PyConZA 2017 5 South Africa Needs Development and Growth •

    Education • Health care • Infrastructure • Research and development • Social upliftment • Poverty reduction • Who will pay the bill?
  5. PyConZA 2017 9 SA Mining and Metals Industry • Several

    challenges: – Rising electricity cost – Labour unrest, increasing cost, productivity – Declining ore quality – Brain drain • Chrome specifically – Difficult to compete – SA chromite mineralogy (low Cr:Fe ratio) – Volatile chrome market – Competition • Current status: – Smelters closing down – Less value add – Increasing ore exports – We are getting less from our minerals
  6. PyConZA 2017 11 Ex Mente • What does it mean?

    – “From the Mind” • Who are we? – Metallurgical and chemical engineers – Software engineers • What do we do? – Consulting – Modelling and simulation – Process control – Information systems • What do we like? – Real understanding – Deep insight – Solving difficult problems – Hot stuff • How do we do it? – Building relationships – R&D – Software
  7. PyConZA 2017 17 Thermochemistry • Also called: chemical thermodynamics •

    The good: – Incredibly powerful for high-temperature processes – Provides really good estimates of what happens • The not so good: – Quite abstract – Many people find it difficult – Often misunderstood, poorly used
  8. PyConZA 2017 18 J.W. Gibbs (1839 – 1903) The father

    of thermochemistry. "Only one man lived who could understand Gibbs's papers. That was Maxwell, and now he is dead." (Rukeyser 251)
  9. PyConZA 2017 19 Thermochemistry • How do we get the

    benefits of thermochemistry to industry? • Sell them specialist software (limited success so far) • Do everything for them (modelling, simulation, investgation) (not enough capacity) • Put thermochemistry into their hands in a way that they can use it (let’s try)
  10. PyConZA 2017 21 A Long Journey • 1993 – 1998

    – Gibbs energy miniser in C++ – Painful!!! – Flow charts in Gensym G2 (ThermoLab) – Expensive!!! • 1999 – 2004 – Buy ChemApp Gibbs energy minimiser – Integrate with Excel, VBA, VB (ThermoLab) – Great strides • 2005 – 2012 – Integrate ChemApp with .Net (C#) – UI with WPF (EMSIM) • 2013 – current – Big move to open source – Integrate ChemApp with Python – UI becomes web-based (EMSIM) – Cloud servers
  11. PyConZA 2017 23 auxi Motivation • Name derived from Latin

    – auxilio (help) – auxillium (helper) • Provide some help to the metallurgical industry • University of Pretoria engineering faculty – Teach Python in second year • Put tools in the hands of process engineers to be more productive
  12. PyConZA 2017 24 auxi Functionality • Tools – Chemistry –

    Material physical properties – Transport phenomena • Modelling – Metallurgical processes – Financial – Business
  13. PyConZA 2017 26 auxi Collaboration • We welcome – suggestions

    – contributions – users – collaborators
  14. PyConZA 2017 28 ChemAppPy Background • auxi can do quite

    a bit • It cannot describe detailed thermochemistry • We need quite a bit more – Complex, multi-phase equilibria – Phase diagrams – Etc.
  15. PyConZA 2017 29 ChemAppPy Background • FactSage (commercial) – Interactive

    UI – Fantastic tool – Difficult for high work loads • ChemApp (commercial) – C and Fortran API – Flexible and powerful – Difficult to master and use – Cryptic API • ChemAppPy raw – ChemApp in Python – Direct API port – Cryptic API • ChemAppPy friendly – Friendly API – Complete flexibility – Rapid development – Rich, productive environment – Quick to master
  16. PyConZA 2017 30 ChemAppPy Friendly Core Concepts • Calculations –

    ChemAppPy high-level commands (a little code does a lot) – Parallel execution • Storage – Thermochemical systems (all details) – Equilibrium calculation results (all details) – Package in json format – Store in mongodb (roughly 512 kB per calculation) • Visualisation – ChemAppPy high-level commands – Matplotlib
  17. PyConZA 2017 31 ChemAppPy Case Study Chrome Ore Reduction Behaviour

    – Open System • Add carbon to reduce the ore • Progressively increase temperature
  18. PyConZA 2017 42 ChemAppPy Case Study Summary Investigation 1 2

    3 Number of calcs 22,982 28,393 10,663 Storage space 4.2 GB 4.8 GB 3.54 GB Number of graphs 2,204 ~2,000 1,500 Number of reports 7 5 6
  19. PyConZA 2017 43 ChemAppPy Case Study Summary • Imagine –

    Please do it for these new ores – Sorry, I gave you the wrong assay – Oops, I made a mistake • Visualisation important for understanding • Optimisation now becomes feasible
  20. PyConZA 2017 45 EMSIM Requirements • Model processes quickly and

    easily • Minimise the amount of programming • Minimise IT impact • Models must be – easy to understand; – well documented; – easily accessible to co-workers and customers; – re-usable. • It must be easy to run large numbers of scenarios
  21. PyConZA 2017 46 EMSIM Core Concepts • Calculations – Steady-state

    mass and energy balances – Detailed thermochemistry in the background (ChemAppPy Friendly) – Python modelling and material frameworks • Storage – Model configuration (all details) – Calculation results (all details) – Package in json format – Store in PostgreSQL • Stack – Django app (via Nginx and Gunicorn) – Celery for background work – HTML, Javascript, CSS
  22. PyConZA 2017 48 Conclusion • Python is an important enabling

    technology • Large-scale thermochemical investigations are feasible • Many possible applications: – New process development – Optimisation – Etc. • We can get thermochemistry in the hands of more people to grow the industry, and SA
  23. PyConZA 2017 49 We are hiring! • Have a look:

    http://ex-mente.co.za/careers/ • Contact us: [email protected] Thank You