Author Topic: Chemical Reaction Analysis (Graphical Lua program)  (Read 8260 times)

0 Members and 1 Guest are viewing this topic.

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Chemical Reaction Analysis (Graphical Lua program)
« on: October 31, 2011, 08:37:52 am »
(By the way, don't think that I'm talking about me at the third-person : this is a translation I've done of the original TI-Planet article ;-)  )

Another exclusive TI-Planet program today!

Our dear member Adriweb, after releasing the Chemical Reaction analysis program for TI-83 + / 84 + ( http://tiplanet.org/forum/archives_voir.php?id=1308 ) , has now programmed its Nspire version ! This is a first on this calculator, especially as it profits from the main new feature offered by the OS 3 : Lua Scripting, like the program TabVar 3, presented yesterday.

This .tns document actually consists of two parts:
-> You run the program (TI-Basic) avancement() and follow the steps to provide information on the chemical reaction to be studied.
-> Go to the next tab and watch the table drawn in detail and in color (Nspire CX only) !

A screenshot?


This program is open source and licensed under the Creative Commons BY-SA 2.0.
Source code : https://github.com/adriweb/Tableau-d-Avancement-LUA/blob/master/TableauAvancement.lua

Link the topic of TIPlanet (more info + download ....): http://tiplanet.org/forum/viewtopic.php?f=43&t=8385

Download link directly : http://tiplanet.org/index.php?mod=archives&ac=voir&id=3754
(Click on the "Telecharger" button)

TI-Planet.org : the website that creates smart programs !


By the way, Happy Halloween;-)
« Last Edit: November 02, 2011, 11:08:59 am by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: Chemical Reaction Analysis (Graphical Lua program)
« Reply #1 on: October 31, 2011, 08:41:38 am »
Nice work !

It is really useful...

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Chemical Reaction Analysis (Graphical Lua program)
« Reply #2 on: October 31, 2011, 08:44:26 am »
Thanks !

I still have to improve the zoom (that works) and pan (that doesn't :P)
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Chemical Reaction Analysis (Graphical Lua program)
« Reply #3 on: October 31, 2011, 08:52:10 am »
nice, you should translate it to english.
I'm not a nerd but I pretend:

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Chemical Reaction Analysis (Graphical Lua program)
« Reply #4 on: October 31, 2011, 08:56:37 am »
Sure :-)

Thanks
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Chemical Reaction Analysis (Graphical Lua program)
« Reply #5 on: October 31, 2011, 08:57:42 am »
* Yeong wants
It looks great!
Sig wipe!

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Chemical Reaction Analysis (Graphical Lua program)
« Reply #6 on: October 31, 2011, 08:59:18 am »
Good work!

All the recent Lua programs that come out show that (Nspire) Lua is pretty good, and with some programming skills you can make wonderful stuff :)

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Chemical Reaction Analysis (Graphical Lua program)
« Reply #7 on: November 01, 2011, 02:29:56 pm »
All right, I finished the translation and updated the graphical and rounding routines at the same time.

The updated version has been posted, and it's at the same place on TI-Planet :
http://tiplanet.org/index.php?mod=archives&ac=voir&id=3754
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Chemical Reaction Analysis (Graphical Lua program)
« Reply #8 on: November 01, 2011, 03:06:45 pm »
This is awesome. If that wasn't for the fact Omni news are exclusively for calc gaming and calc games development related stuff, that would easily go there.

I'll probably check this out when I have a chance.

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Chemical Reaction Analysis (Graphical Lua program)
« Reply #9 on: November 01, 2011, 03:40:49 pm »
All right, I finished the translation and updated the graphical and rounding routines at the same time.

The updated version has been posted, and it's at the same place on TI-Planet :
http://tiplanet.org/index.php?mod=archives&ac=voir&id=3754
It's it for cas version only?
Sig wipe!

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Chemical Reaction Analysis (Graphical Lua program)
« Reply #10 on: November 02, 2011, 06:26:00 am »
Updated the archive and everything again.

It now comes with a real chemical equation for the demo >.> (sorry, lol)

It should work for non-CAS.

Here's the TI-Basic part source code :

Code: [Select]
Define LibPub avancement_en()=
Prgm
:Local i,tmp1
:DelVar lnoms
:DelVar lmoles
:DelVar lcoeff
:DelVar lreste
:DelVar reactlim
:luasignal:=−1337
:nbrreact:=0: nbrprod:=0
:While nbrreact=0
:   Request "How many reagants ? ",nbrreact
:EndWhile
:For i,1,nbrreact
:   RequestStr "Symbol of reagent n°"&string(i)&" ? ",lnoms[i]
:   Request "Coefficient of reagent n°"&string(i)&" ? ",lcoeff[i]
:   Request "How many moles of reagant n°"&string(i)&" ? ",lmoles[i]
:EndFor
:Disp "---------"
:While nbrprod=0
:   Request "How many product(s) ? ",nbrprod
:EndWhile
:For i,nbrreact+1,nbrreact+nbrprod
:   RequestStr "Symbol of product n°"&string(i-nbrreact)&" ? ",lnoms[i]
:   Request "Coefficient of product n°"&string(i-nbrreact)&" ? ",lcoeff[i]
:   Request "How many moles of product n°"&string(i-nbrreact)&" ? ",lmoles[i]
:EndFor
:Disp "---------"
:reactlim:=0
:xmax:=9000
:For i,1,nbrreact
:   tmp1:=((lmoles[i])/(lcoeff[i]))
:   If tmp1<xmax Then
:       reactlim:=reactlim+1
:       xmax:=tmp1
:   Else
:       If tmp1=xmax Then
:           xmax:=−1
:       EndIf
:   EndIf
:EndFor
:If xmax>0 Then
:    Disp "Limitant reagent : n°",reactlim
:    Disp "Xmax = ",approx(xmax)," mol."
:Else
:    xmax:=((lmoles[1])/(lcoeff[1]))
:    Disp "Stoechiometrical proportions."
:    Disp "Xmax = ",approx(xmax)," mol."
:EndIf
:For i,1,nbrreact
:    lreste[i]:=approx(lmoles[i]-xmax)
:    If i≠reactlim Then
:       Disp "There is/are ",approx(lmoles[i]-xmax)," moles of ",lnoms[i]," left."
:    Else
:       lreste[i]:=0
:       Disp "There is no more ",lnoms[i]
:    EndIf
:EndFor
:For i,nbrreact+1,nbrreact+nbrprod
:    lreste[i]:=approx(lmoles[i]+lcoeff[i]*xmax)
:    Disp lreste[i]," moles of ",lnoms[i]," has/have been made."
:EndFor
:xmax:=string(approx(xmax))
:luasignal:=42+rand()
:Disp "---------"
:Disp "The summary table is in the following tab."
:EndPrgm

Screenshot of version 1.25 :
« Last Edit: November 02, 2011, 06:31:59 am by adriweb »
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Chemical Reaction Analysis (Graphical Lua program)
« Reply #11 on: November 02, 2011, 07:42:57 am »
Yay, good work!