maxima : display chemical reactions with 'itensor',version 1.0
peter.vlasschaert@gmail.com,30/10/2020

load packages ,option 
=================

load(lrats)$

load(itensor)$

a) simple reaction 
==============

→ products

s1:ishow(H([2],[])*SO([4],[]))$ 

s2:ishow(Na([],[])*OH([],[]))$ 

s3:ishow(Na([2],[])*SO([4],[]))$ 

s4:ishow(H([2],[]).O([],[]))$  

→  display 'reaction'

ishow(s1+2*s2=s3+2*s4)$

b)  simple  product
===============

https://nl.wikipedia.org/wiki/Kaliumdichromaat

v1:2$
v2:2$
v3:7$

s5:ishow(K([v1],[]).Cr([v2],[]).O([v3],[]))$

c)  simple redox reaction (acid medium)
===============================
superscript = charge of the atom ( ≠ syntax,chemical)
subscript     = number of atoms    ( "chemical")

→ products

s6:ishow(Mn([],[]).O([4],[-1]))$

s7:ishow(H([],[+1]))$

s8:ishow(e([],[-1]))$

s9:ishow(Mn([],[+2]))$

s10:ishow(H([2],[]).O([],[]))$

→  display 'reaction'

ishow(s6+8*s7+5*s8 = s9+4*s10)$

charge : -1+8-5 = 2

rem : atom ,'syntax' from maxima.
rem : particle  → e = electron , charge superscript

info
===

→  replace

v11:K$
v22:Cr$
v33:O$

s11:ishow(v11([v1],[]).v22([v2],[]).v33([v3],[]))$

→ definition : products. 
      zi : chemical element
      zii: number of atoms from chemical element ( = zi)
      ---------------------------------------------------------------------
      i=1,2,3, .........

s12:prodch(z1,z11,z2,z22,z3,z33):=block([],
ishow(z1([z11],[]).z2([z22],[]).z3([z33],[]))
)$

grind(prodch)$

→ example," prodch "
=================

https://nl.wikipedia.org/wiki/Natriumthiosulfaat

sa:prodch(Na,2,S,2,O,3)$

s13:prodnch(nc,z1,z11,z2,z22,z3,z33):= block([],
    if nc=1 then  
    ishow(z1([z11],[]))
    else if (nc=2) then
    ishow(z1([z11],[]).z2([z22],[]))
    else if (nc=3) then
    ishow(z1([z11],[]).z2([z22],[]).z3([z33],[]))
)$

grind(prodnch)$

rem : nc = 1 or nc = 2  or nc = 3,number of elements.

→ example," prodnch "
=================

https://nl.wikipedia.org/wiki/Natriumoxide

sb:prodnch(2,Na,2,O,1,0,0)$

info: "ishow from ishow"

sc:ishow(sa+sb);

sc1:ishow(sa+sb)$