summaryrefslogtreecommitdiffstats
path: root/subsurface-core/dive.c
AgeCommit message (Collapse)Author
2016-03-02gas model: split up gas compressibility into a file of its ownGravatar Linus Torvalds
The gas compressibility is such a specialized thing that I really prefer having it separate. This keeps Robert's Redlich-Kwong equation as-is, but let's experiment with other models soon... Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-29This computes the compressibility of the gas depending on the mixture.Gravatar Robert C. Helling
As it turns out, the van der Waals equation gives results that are numerically not really useful, so we use the Redlich Kwong equation which is, according to Wikipedia, much more accurate, which can be confirmed given the empirical values for air. As opposed to the previous approach with a look-up table, this takes into account the actual gasmix. This always assumes the gas to be at 20 degrees Centigrade. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-28If salinity is not density, add density of fresh waterGravatar Robert C. Helling
There was a reported case of an import of a dive that gave a salinity of 35g/l. This is an actual salinity (an amount of salt in the water) but for subsurface the salinity is actually the density of the water. So for too small values of the salinity add the density of fresh water. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-25gas pressures: use an actual compressibility table for airGravatar Linus Torvalds
We could in theory make this dependent on the gasmix, but for now let's just assume (incorrectly) that everything we breathe acts like air. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-25gas pressures: do not use gas compressibility for cylinder namingGravatar Linus Torvalds
This actually didn't make a difference for the common case, since our simplified gas compressibility model had a compressibility factor of 1.0 up to 200 bar, and increased smoothly from there. As a result, the common 2400 and 3000 psi workpressures didn't really see an effect from this. Not taking compressibility into account does kind of make sense for cylinder naming, since the cylinder may be used for different gases with very different compressibility characteristics. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-25gas pressures: do some initial cleanupGravatar Linus Torvalds
This marks "surface_volume_multiplier()" static in preparation for changing it to use an actual honest-to-goodness compressibility estimation. Without that, it wasn't obvious that the function wasn't used in other random places. Also, remove the "wet_volume()" function. It was unused, but more importantly, it was wrong. Yes, it was the inverse of "gas_volume()", but when you calculate wet volumes from the imperial sizes, you don't actually use the "real" gas volume, you use the idealized one. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-20Add option to allocate the samples in fake_dc()Gravatar Dirk Hohndel
We (ab)use fake_dc() to create a pleasing profile for a manually added dive. Based on it's intended use, fake_dc() simply handed back a dc structure that pointed at staticly allocated samples - that's obviously (now that I think about it) going to blow up in my face if I edit a manually added dive more than once. So now we have an option for fake_dc() to actually allocate the samples - this way the rest of the code can treat these samples as we would treat samples created any other way. We can free them and replace them with a new set. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-04Allow merging of dives with zero depth/durationGravatar Miika Turkia
Fixes #1003 Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-07Assign lower number to a merged dive instead of higher oneGravatar Salvador Cuñat
At the moment, if we have, say, dives ... 100, 101 and 102 and we merge 101 and 102, we get a list numbered ... 99, 100, 102. This is, probably, an undesired behavior. The patch simple chooses lower of both dive numbers instead of higher one. Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-27dive: paren error in set point handlingGravatar Stephen Hemminger
This probably is a serious bug, found by cppcheck. Original code had paren's in probably the wrong place! Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-12-03Prevent gaschange tank icons from using garbage coords.Gravatar K. \"pestophagous\" Heller
Tank icons were shown at incorrect spots on the profile when the DiveEventItem object held a pointer to a struct event even after the struct event at that address had been freed. When internalEvent is a pointer to freed memory, internalEvent->time.seconds could have all kinds of crazy values, which get used in member function DiveEventItem::recalculatePos to place the tank at bad x coordinates. The DiveEventItem(s) no longer store a pointer to memory that they do not own. This way, no matter how the path of execution arrives into slot recalculatePos, we never need fear that the DiveEventItem will dereference a garbage pointer to a struct event. Fixes #968 Signed-off-by: K. Heller <pestophagous@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-16dive.c: fix a couple of comment typosGravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-15simple spelling changesGravatar Stephen Hemminger
Fix obvious spelling mistakes in comments (and one error message). Yes, this is trivial but I saw one while reviewing some of the code and after that decided to run code through some tools. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-07dive.c: remove unused variableGravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-10-30Move all core-functionality to subsurface-coreGravatar Tomaz Canabrava
And adapt a new CMakeLists.txt file for it. On the way I've also found out that we where double-compilling a few files. I've also set the subsurface-core as a include_path but that was just to reduce the noise on this commit, since I plan to remove it from the include path to make it obligatory to specify something like include "subsurface-core/dive.h" for the header files. Since the app is growing quite a bit we ended up having a few different files with almost same name that did similar things, I want to kill that (for instance Dive.h, dive.h, PrintDive.h and such). Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>