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
Tried it? Did this program work on your calculator?
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.
TI-84 Plus CE Python · screen preview
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
- 1 finds pressure. 2 finds temperature.
- 3 compares the real-gas pressure with the ideal gas law. 4 finds a or b.
- Constants a and b are different for every gas and come from a table.
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
- Use liters, atmospheres, and kelvin, with a and b in matching units.
- The volume must be larger than n*b or the program stops with a message.
- A larger a means stronger attraction; a larger b means bigger molecules.
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
R=.082057def intro(n):print("+----------------------+");print("| "+n+" |");print("| ___(o )> quack! |");print("| by DuckieDai |");print("+----------------------+");input("ENTER to start: ")def num(s):while 1:try:return float(input(s))except:print("Enter a number")def pos(s):while 1:x=num(s)if x>0:return xprint("Must be positive")def nonneg(s):while 1:x=num(s)if x>=0:return xprint("Must be 0 or more")def pick(s,m):while 1:try:x=int(input(s))if x>0 and x<=m:return xexcept:passprint("Invalid choice")intro("VAN DER WAALS")print("1 Pressure 2 Temp");print("3 Real vs ideal 4 Find a/b")c=pick("Choose 1-4: ",4)if c==1 or c==3:n=pos("Moles n: ");v=pos("Volume L: ");t=pos("Temp K: ");a=nonneg("a: ");b=nonneg("b: ")if v<=n*b:print("Need V > n*b")elif c==1:print("P atm =",n*R*t/(v-n*b)-a*n**2/v**2)else: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)elif c==2:p=pos("P atm: ");n=pos("Moles n: ");v=pos("Volume L: ");a=nonneg("a: ");b=nonneg("b: ")if v<=n*b:print("Need V > n*b")else:print("T K =",(p+a*n**2/v**2)*(v-n*b)/(n*R))else: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: ")if q==1:b=nonneg("b: ")if v<=n*b:print("Need V > n*b")else:print("a =",v**2/n**2*(n*R*t/(v-n*b)-p))else:a=nonneg("a: ");print("b =",(v-n*R*t/(p+a*n**2/v**2))/n)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
- 1.0.0 — current version, published . Download this reviewed version
Related learning
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.