ibell / coolprop

Deprecated version - go to
https://github.com/CoolProp/CoolProp
MIT License
24 stars 16 forks source link

Fluent wrapper progress #151

Closed ghobold closed 10 years ago

ghobold commented 10 years ago

I have started using the Fluent wrapper and it seems to be working fine. I made a basic UDF to integrate the library with the solver itself (so Fluent is able to probe properties from Coolprop while computing the solution, instead of a "execute on demand" program as before). Fluent has a bult-in NIST real gas model for several fluids (for some reason, not for air) which I used to compare the results obtained with Coolprop. I ran a simple example of forced convection (isothermal circular wall, laminar, Re ≃ 1000) with CO2 as working fluid and produced the charts below. Both NIST-REPROP and COOLPROP libraries use the same equation of state, so the results are pretty much equal.

chart005 chart004 chart003 chart002

(The percentage in the legends indicate how close to the end of the pipe the profile is)

Computational time-wise, Coolprop seems to take longer to retrieve the results than the bult-in REFPROP, causing larger iteration times. However, the Coolprop model converges in less iterations and seems to be more stable than the NIST model. One thing I would like to add is that, for now, the UDF I made does not support specific heat as a function of pressure, which is no big deal unless we're near the critical point, but I will fix this soon. My fear is that making c_p as a function of pressure will increase the CPU time too much, but we will see. Here is a Fluent report using both models:

### Using Coolprop

  Performance Timer for 27 iterations on 6 compute nodes
  Average wall-clock time per iteration:              1.543 sec
  Global reductions per iteration:                      491 ops
  Global reductions time per iteration:               0.000 sec (0.0%)
  Message count per iteration:                        14555 messages
  Data transfer per iteration:                        4.902 MB
  LE solves per iteration:                                4 solves
  LE wall-clock time per iteration:                   0.068 sec (4.4%)
  LE global solves per iteration:                        21 solves
  LE global wall-clock time per iteration:            0.000 sec (0.0%)
  LE global matrix maximum size:                        31
  AMG cycles per iteration:                          40.741 cycles
  Relaxation sweeps per iteration:                     3317 sweeps
  Relaxation exchanges per iteration:                  2374 exchanges

  Total wall-clock time:                             41.665 sec
  Total CPU time:                                   250.890 sec

### Using NIST real gas model

  Performance Timer for 56 iterations on 6 compute nodes
  Average wall-clock time per iteration:              0.494 sec
  Global reductions per iteration:                      352 ops
  Global reductions time per iteration:               0.000 sec (0.0%)
  Message count per iteration:                        15205 messages
  Data transfer per iteration:                        4.721 MB
  LE solves per iteration:                                4 solves
  LE wall-clock time per iteration:                   0.052 sec (10.6%)
  LE global solves per iteration:                        33 solves
  LE global wall-clock time per iteration:            0.001 sec (0.1%)
  LE global matrix maximum size:                        31
  AMG cycles per iteration:                          44.339 cycles
  Relaxation sweeps per iteration:                     3381 sweeps
  Relaxation exchanges per iteration:                  1906 exchanges

  Total wall-clock time:                             27.664 sec
  Total CPU time:                                   167.610 sec

I can upload the UDF I used and the Fluent mesh/case files if that's of interest to serve as an example to other people who might want to use Coolprop with Fluent.

ibell commented 10 years ago

Awesome!!! Yes we can definitely add this as example files for Fluent! I am curious to know what state variables you use. If it's temperature and density we should be faster than NIST, if its temperature and pressure, REFPROP is faster. I'm not sure why, but they are.

In any case, this looks really really great.

How big are the files? If they aren't too large it would be nice to have everything you have here online in the git repo

Do you have any experience with OpenFOAM?

Thanks so much for your contribution!

On Fri, Feb 21, 2014 at 7:39 PM, ghobold notifications@github.com wrote:

I have started using the Fluent wrapper and it seems to be working fine. I made a basic UDF to integrate the library with the solver itself (so Fluent is able to probe properties from Coolprop while computing the solution, instead of a "execute on demand" program as before). Fluent has a bult-in NIST real gas model for several fluids (for some reason, not for air) which I used to compare the results obtained with Coolprop. I ran a simple example of forced convection (isothermal circular wall, laminar, Re ≃ 1000) with CO2 as working fluid and produced the charts below. Both NIST-REPROP and COOLPROP libraries use the same equation of state, so the results are pretty much equal.

[image: chart005]https://f.cloud.github.com/assets/6594415/2233117/e1b2c4b0-9b25-11e3-9c24-35ed9d6ac2bc.png [image: chart004]https://f.cloud.github.com/assets/6594415/2233118/e1b343cc-9b25-11e3-903c-b2f4a74c425e.png [image: chart003]https://f.cloud.github.com/assets/6594415/2233120/e1b47760-9b25-11e3-8aa6-a6cb700c1684.png [image: chart002]https://f.cloud.github.com/assets/6594415/2233119/e1b47954-9b25-11e3-83a2-bbe5986f5880.png

(The percentage in the legends indicate how close to the end of the pipe the profile is)

Computational time-wise, Coolprop seems to take longer to retrieve the results than the bult-in REFPROP, causing larger iteration times. However, the Coolprop model converges in less iterations and seems to be more stable than the NIST model. One thing I would like to add is that, for now, the UDF I made does not support specific heat as a function of pressure, which is no big deal unless we're near the critical point, but I will fix this soon. My fear is that making c_p as a function of pressure will increase the CPU time too much, but we will see. Here is a Fluent report using both models:

Using Coolprop

Performance Timer for 27 iterations on 6 compute nodes Average wall-clock time per iteration: 1.543 sec Global reductions per iteration: 491 ops Global reductions time per iteration: 0.000 sec (0.0%) Message count per iteration: 14555 messages Data transfer per iteration: 4.902 MB LE solves per iteration: 4 solves LE wall-clock time per iteration: 0.068 sec (4.4%) LE global solves per iteration: 21 solves LE global wall-clock time per iteration: 0.000 sec (0.0%) LE global matrix maximum size: 31 AMG cycles per iteration: 40.741 cycles Relaxation sweeps per iteration: 3317 sweeps Relaxation exchanges per iteration: 2374 exchanges

Total wall-clock time: 41.665 sec Total CPU time: 250.890 sec

Using NIST real gas model

Performance Timer for 56 iterations on 6 compute nodes Average wall-clock time per iteration: 0.494 sec Global reductions per iteration: 352 ops Global reductions time per iteration: 0.000 sec (0.0%) Message count per iteration: 15205 messages Data transfer per iteration: 4.721 MB LE solves per iteration: 4 solves LE wall-clock time per iteration: 0.052 sec (10.6%) LE global solves per iteration: 33 solves LE global wall-clock time per iteration: 0.001 sec (0.1%) LE global matrix maximum size: 31 AMG cycles per iteration: 44.339 cycles Relaxation sweeps per iteration: 3381 sweeps Relaxation exchanges per iteration: 1906 exchanges

Total wall-clock time: 27.664 sec Total CPU time: 167.610 sec

I can upload the UDF I used and the Fluent mesh/case files if that's of interest to serve as an example to other people who might want to use Coolprop with Fluent.

— Reply to this email directly or view it on GitHubhttps://github.com/ibell/coolprop/issues/151 .

ghobold commented 10 years ago

I'm using temperature and pressure, I am not sure if Fluent supports temperature and density, but I will look into that. The mesh/cash files are about ~3mb each. The biggest files (data ones) are about ~30mb each (two of them, one for Coolprop and other for REFPROP). That's probably because I used a very fine mesh, but I will add them and you see if they are worth it.

I don't have any experience with OpenFOAM, unfortunately.

And it's my pleasure to be able to contribute, I hope I can do more in the future!

ghobold commented 10 years ago

How can I add files that are neither text or code? Do I need git?

ibell commented 10 years ago

The EOS are all of the form p(T,rho), so if you use T,p as state variables, you will always have to iterate on the density to get the imposed pressure. This takes quite some time (4x slower) and if you can, you should really use T,rho as inputs. You'll see a large speedup!

On Fri, Feb 21, 2014 at 8:00 PM, ghobold notifications@github.com wrote:

I'm using temperature and pressure, I am not sure if Fluent supports temperature and density, but I will look into that. The mesh/cash files are about ~3mb each. The biggest files (data ones) are about ~30mb each (two of them, one for Coolprop and other for REFPROP). That's probably because I used a very fine mesh, but I will add them and you see if they are worth it.

I don't have any experience with OpenFOAM, unfortunately.

And it's my pleasure to be able to contribute, I hope I can do more in the future!

Reply to this email directly or view it on GitHubhttps://github.com/ibell/coolprop/issues/151#issuecomment-35761588 .

ibell commented 10 years ago

I think you might need git to push them. They are really quite large, so I wonder about making another repo for the bigger files, something along the lines of coolprop-supplemental or something like that.

And then we could have another repo that is nightly builds of all of the installers for all the languages for all of the platforms. I could set up virtual images to do all of this on my machine I think.

ghobold commented 10 years ago

OK, I think that's a good idea. Let me know if you decide to do that so I can push the example. I will document the UDF in the README.

ibell commented 10 years ago

coolprop-supplemental is now at https://github.com/coolprop/coolprop-supplemental . Go ahead with a pull request

ghobold commented 10 years ago

Great, I will do that on Monday, as only then I will have access to my lab computer. I also managed to use density and temperature as variables for thermal conductivity and viscosity, and the computation time reduced to ~35 seconds, still a little slower than NIST. I will look into using the density-based solver instead of the pressure-based solver in Fluent, then solving for pressure as function of density and temperature, instead of solving for density as a function of pressure and temperature. That might give Coolprop an advantage.

ibell commented 10 years ago

So what are the timings now if you use temperature and density as state variables?

On Sat, Feb 22, 2014 at 8:59 PM, ghobold notifications@github.com wrote:

Great, I will do that on Monday, as only then I will have access to my lab computer. I also managed to use density and temperature as variables for thermal conductivity and viscosity, and the computation time reduced to ~35 seconds, still a little slower than NIST. I will look into using the density-based solver instead of the pressure-based solver in Fluent, then solving for pressure as function of density and temperature, instead of solving for density as a function of pressure and temperature. That might give Coolprop an advantage.

Reply to this email directly or view it on GitHubhttps://github.com/ibell/coolprop/issues/151#issuecomment-35812857 .

ghobold commented 10 years ago

As mentioned, I was only able to use thermal conductivity and viscosity as a function of T and rho. The clock time was ~35 seconds compared to the ~27 seconds by REFPROP. I will look into the Fluent density-based solver (the default is pressure-based) so we can use p = p(T, rho) instead of rho = rho(p, T). This should reduce the time as well.

ghobold commented 10 years ago

OK, I think I managed to make a pull request of the example files using git, took me a while to figure out how to use it, though. I will document the example soon.

By the way, I believe, that, for now, ~35 seconds against the REFPROP's ~27 seconds is as good as it gets, apparently. I don't know why REFPROP is faster, though, perhaps because it is already integrated in Fluent rather than loaded as an external library. I'm not really sure how this integration occurs.

ghobold commented 10 years ago

I changed Props() to PropsSI() and Coolprop seems to be at least as fast as REFPROP now, only more stable and taking less iterations.

## Coolprop

Performance Timer for 27 iterations on 6 compute nodes
  Average wall-clock time per iteration:              1.010 sec
  Global reductions per iteration:                      491 ops
  Global reductions time per iteration:               0.000 sec (0.0%)
  Message count per iteration:                        14571 messages
  Data transfer per iteration:                        4.907 MB
  LE solves per iteration:                                4 solves
  LE wall-clock time per iteration:                   0.060 sec (5.9%)
  LE global solves per iteration:                        21 solves
  LE global wall-clock time per iteration:            0.000 sec (0.0%)
  LE global matrix maximum size:                        31
  AMG cycles per iteration:                          40.741 cycles
  Relaxation sweeps per iteration:                     3319 sweeps
  Relaxation exchanges per iteration:                  2376 exchanges

  Total wall-clock time:                             27.270 sec
  Total CPU time:                                   163.410 sec
ibell commented 10 years ago

Yeah I pulled your PR, take a look at my comments, I think you can still make it faster!

On Tue, Feb 25, 2014 at 2:31 PM, Gustavo notifications@github.com wrote:

I changed Props() to PropsSI() and Coolprop seems to be at least as fast as REFPROP now, only more stable and taking less iterations.

Coolprop

Performance Timer for 27 iterations on 6 compute nodes Average wall-clock time per iteration: 1.010 sec Global reductions per iteration: 491 ops Global reductions time per iteration: 0.000 sec (0.0%) Message count per iteration: 14571 messages Data transfer per iteration: 4.907 MB LE solves per iteration: 4 solves LE wall-clock time per iteration: 0.060 sec (5.9%) LE global solves per iteration: 21 solves LE global wall-clock time per iteration: 0.000 sec (0.0%) LE global matrix maximum size: 31 AMG cycles per iteration: 40.741 cycles Relaxation sweeps per iteration: 3319 sweeps Relaxation exchanges per iteration: 2376 exchanges

Total wall-clock time: 27.270 sec Total CPU time: 163.410 sec

Reply to this email directly or view it on GitHubhttps://github.com/ibell/coolprop/issues/151#issuecomment-36007019 .

ghobold commented 10 years ago

Thanks! As I said in my comment, I don't know how to somehow replace the DEFINE_PROPERTY macro for density, but I will keep my eyes open. What I want to do now is find a way to make specific heat a function of something else other than only temperature (temperature and density would be ideal).

ibell commented 10 years ago

Good luck with that! I'm closing this issue for now, let me know if you need anything

On Tue, Feb 25, 2014 at 3:16 PM, Gustavo notifications@github.com wrote:

Thanks! As I said in my comment, I don't know how to somehow replace the DEFINE_PROPERTY macro for density, but I will keep my eyes open. What I want to do now is find a way to make specific heat a function of something else other than only temperature (temperature and density would be ideal).

Reply to this email directly or view it on GitHubhttps://github.com/ibell/coolprop/issues/151#issuecomment-36010877 .