|
Boost : |
Subject: Re: [boost] [units] - learning to use, continued :)
From: Janek Kozicki (janek_listy_at_[hidden])
Date: 2011-11-29 16:19:04
Hi,
thanks for examples to make scaled units (nm, km, GJ, etc..).
I'll get to this soon.
BTW, sorry for sending previous email twice. I pressed "send"
keyboard shortcut too early.
Today I wanted to finish my quantum wavefunction harmonic oscillator.
I was working on it, while in parallel compiling & trying to install
boost 1.48, which currently was unsuccessful (debian squeeze).
BTW, if anybody has a hint about how to install boost 1.48 on debian
squeeze using preferably using the "legal"
`dpkg-buildpackage -rfakeroot -b` way, it would be great.
But still I am quite happy today, because I managed to get a
correctly working plots of this harmonic oscillator, but without
units, unfortunately. One small problem is that I couldn't get to
higher energies because double precision has limited factorials.
I would need a working factorial of 100! which currently seems
unlikely. And my currently maximum is only 25!
I didn't check yet, but maybe boost has some arbitrary precision
library, which would work with Boost.Units and
boost::math::factorial ?
So, for your pleasure I am presenting you with a harmonic oscillator code :)
Unfortunately without units :) But if you will try to convert this to
units, I might learn even more about using this library. Especially
because dimension of wavefunction in 1 dimensional space is
1/sqrt(meter), and I have no idea how to declare this
derived_dimension, this didn't work:
typedef derived_dimension<length_base_dimension,root<2> >::type quantum_wavefunction_1D;
In the attachment you will find a plot and code for frequency=1Hz,
hbar=1 J*s, mass=1kg (plotted against a classical harmonic
oscillator). Which you can compare with wikipedia and admire how
similar they are :) (note that I take Planck's constant to be 1, for
start).
So things to do:
- install boost 1.48 on my PC
- make promised scaled SI units
- convert this harmonic oscillator code to use Boost.Units
- find some arbitrary precision library, that will work with Units
and VERY big factorials, like 100! or even better 1000!
I hope you enjoy this code. I like it :)
best regards
-- Janek Kozicki http://janek.kozicki.pl/ |
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk