Hidden WordScanner
Private scans · No account required

DuckieDai Van der Waals Real-Gas Equation

Solve the van der Waals equation for pressure or temperature, compare with the ideal gas law, or rearrange for a or b.

chemistry · MIT License

Overview

Solve the van der Waals equation for pressure or temperature, compare with the ideal gas law, or rearrange for a or b.

  • Not calculator tested
  • Downloaded 32 times
  • Version 1.0.0
  • 1624 bytes
  • No imports

Before you run it

  • TI-84 Plus CE Python · No calculator OS or Python App version has been verified.
  • TI Connect CE .py transfer is the intended path; calculator OS, Python App, transfer, and execution have not yet been tested for this release
  • A single van der Waals parameter pair represents the gas in a single modeled phase.
  • The equation is an educational real-gas approximation, not a high-accuracy equation of state.
  • n, V, and T are positive; supplied a and b are nonnegative; free volume V-n*b must be positive.

Try the DuckieDai calculator screen

Follow the same opening, solve menu, prompts, validation, and result flow as the downloadable program.

JavaScript is required for the optional browser simulation. Source viewing and downloading remain available without it.

Simulation boundary: This preview uses a reviewed browser adapter. It does not execute the downloaded Python and does not prove TI-Python or calculator compatibility.

Learn the math

How the van der Waals equation works

The idea

The ideal gas law treats molecules as points that ignore each other. Real molecules take up space and attract one another, and the van der Waals equation corrects for both.

The differences matter most at high pressure and low temperature, where molecules are crowded.

The formula

(P + a*n^2/V^2)*(V - n*b) = n*R*T

P
pressure (atm)
V
volume (L)
n
moles of gas
T
temperature in kelvin
a
correction for attraction between molecules
b
correction for the volume of the molecules

Using the program

Worked example

One mole of carbon dioxide (a = 3.59, b = 0.0427) occupies 22.4 L at 273.15 K. Choose 1 and enter 1, 22.4, 273.15, 3.59, and 0.0427.

The program shows P atm = 0.995 (it prints more decimal places), slightly below the 1.00 atm the ideal gas law predicts.

Tips and common mistakes

Where this comes up

It follows the ideal gas law in the gases unit of general chemistry and returns in physical chemistry and chemical engineering as the first model of a real gas.

Exact reviewed bytes

Source code

Download .py

View source below, copy it when JavaScript is available, or download the exact .py bytes.

  1. R=.082057
  2. def intro(n):
  3. print("+----------------------+");print("| "+n+" |");print("| ___(o )> quack! |");print("| by DuckieDai |");print("+----------------------+");input("ENTER to start: ")
  4. def num(s):
  5. while 1:
  6. try:return float(input(s))
  7. except:print("Enter a number")
  8. def pos(s):
  9. while 1:
  10. x=num(s)
  11. if x>0:return x
  12. print("Must be positive")
  13. def nonneg(s):
  14. while 1:
  15. x=num(s)
  16. if x>=0:return x
  17. print("Must be 0 or more")
  18. def pick(s,m):
  19. while 1:
  20. try:
  21. x=int(input(s))
  22. if x>0 and x<=m:return x
  23. except:pass
  24. print("Invalid choice")
  25. intro("VAN DER WAALS")
  26. print("1 Pressure 2 Temp");print("3 Real vs ideal 4 Find a/b")
  27. c=pick("Choose 1-4: ",4)
  28. if c==1 or c==3:
  29. n=pos("Moles n: ");v=pos("Volume L: ");t=pos("Temp K: ");a=nonneg("a: ");b=nonneg("b: ")
  30. if v<=n*b:print("Need V > n*b")
  31. elif c==1:print("P atm =",n*R*t/(v-n*b)-a*n**2/v**2)
  32. else:
  33. pi=n*R*t/v;pr=n*R*t/(v-n*b)-a*n**2/v**2;print("Ideal P =",pi);print("Real P =",pr);print("% change =",100*(pr-pi)/pi)
  34. elif c==2:
  35. p=pos("P atm: ");n=pos("Moles n: ");v=pos("Volume L: ");a=nonneg("a: ");b=nonneg("b: ")
  36. if v<=n*b:print("Need V > n*b")
  37. else:print("T K =",(p+a*n**2/v**2)*(v-n*b)/(n*R))
  38. else:
  39. q=pick("1 find a 2 find b: ",2);p=pos("P atm: ");n=pos("Moles n: ");v=pos("Volume L: ");t=pos("Temp K: ")
  40. if q==1:
  41. b=nonneg("b: ")
  42. if v<=n*b:print("Need V > n*b")
  43. else:print("a =",v**2/n**2*(n*R*t/(v-n*b)-p))
  44. else:
  45. a=nonneg("a: ");print("b =",(v-n*R*t/(p+a*n**2/v**2))/n)
  46. input("ENTER for guide: ");print("a=attractions, b=molecule volume");print("V must exceed n*b");print("DuckieDai: done!");input("ENTER to exit: ")
Filename
vdW.py
Size
1624 bytes
SHA-256
eb7eb29ffccdc9186af4f15e996ee6010a55a168c090ff52158359ac61afa476

Usage

Inputs

  • Pressure in atm, volume in L, amount in mol, and temperature in K as required
  • a in L^2*atm/mol^2 and b in L/mol

Outputs

  • Requested pressure, temperature, a, or b
  • Ideal/real pressure comparison and percent change

Units: Use atm, L, mol, K, L^2*atm/mol^2, and L/mol consistently with R = 0.082057 L*atm/(mol*K).

Assumptions and limitations

Assumptions

  • A single van der Waals parameter pair represents the gas in a single modeled phase.
  • The equation is an educational real-gas approximation, not a high-accuracy equation of state.

Constraints

  • n, V, and T are positive; supplied a and b are nonnegative; free volume V-n*b must be positive.

Known failures

  • Solved negative a or b, or calculated nonpositive pressure, indicates inconsistent data or an unsuitable modeled state.
  • Near phase boundaries or the critical region, the equation may give multiple or inaccurate states.

Compatibility and review

Review status
Not calculator tested
Tested on
The owner reports personally testing the supplied archive programs on a calculator; exact model, OS, and Python App versions were not recorded
What happened
Owner reported interactive testing is disclosed, but the published bytes are not labeled independently calculator tested because the environment is unrecorded and Arrhenius received a narrow intake correction
Dependencies
No imports
Suggested calculator name
VDW — you can give it another valid, unique name when you transfer it
Desktop test cases
Not available for this interactive-only source

This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.

Transfer and launch

Download the .py file, send it to your calculator with TI Connect CE as VDW or another name, then open the Python App and try the worked example on this page first. This release has no verified calculator OS or Python App version; treat transfer and execution as unverified until independently tested.

Full installation and troubleshooting guide. Check your teacher's or exam's rules before using any program.

Version history

Did a DuckieDai program help with your homework? Every program here is free. If you would like to say thanks, you can leave a tip on Cash App ($duckiedai214) or read what tips pay for.

Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.

Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters, and so does a Yes or No answer about whether the program worked. Your browser notes that you answered; that note is never sent to the site. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.