Skip to content

Commit d760319

Browse files
committed
reg5
1 parent 100c1dc commit d760319

3 files changed

Lines changed: 41 additions & 4 deletions

File tree

benches/speed_benchmark.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ fn criterion_benchmark(c: &mut Criterion) {
2020
//group.bench_function("tv2h_reg3", |b| b.iter(|| tv(black_box(650.0 - 273.15), black_box(1.0 / 500.0), OH)));
2121
//group.bench_function("tv2s_reg3", |b| b.iter(|| tv(black_box(650.0 - 273.15), black_box(1.0 / 500.0), OS)));
2222
//group.bench_function("pt2h_reg3", |b| b.iter(|| pt(black_box(50.0), black_box(630.0-273.15), OH)));
23-
group.bench_function("pt2s_reg3", |b| b.iter(|| pt(black_box(50.0), black_box(630.0-273.15), OS)));
23+
//group.bench_function("pt2s_reg3", |b| b.iter(|| pt(black_box(50.0), black_box(630.0-273.15), OS)));
2424

2525
//group.bench_function("pt2h_reg5", |b| b.iter(|| pt(black_box(0.5), black_box(1500.0 - 273.15), OH)));
26-
//group.bench_function("pt2s_reg5", |b| b.iter(|| pt(black_box(0.5), black_box(1500.0-273.15), OS)));
26+
group.bench_function("pt2s_reg5", |b| b.iter(|| pt(black_box(0.5), black_box(1500.0-273.15), OS)));
2727

2828
group.finish();
2929
}

src/r5/region5_gfe.rs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,38 @@ pub fn gammar_pitau_reg5(pi: f64, tau: f64) -> f64 {
233233
result += IJn[4].2 * 18.0 * pi * tau_6*tau_2; // I=2,J=9, 18
234234
result += IJn[5].2 * 21.0 * pi*pi * tau_6; // I=3,J=27, 21
235235
return result
236-
// poly_ij_powi(pi, tau, &IJn)
237-
}
236+
// poly_ij_powi(pi, tau, &IJn)
237+
}
238+
239+
// improve performance 10% ,but code complexity is increased
240+
#[inline(always)]
241+
pub fn gammar_pi_tau_reg5(pi: f64, tau: f64) -> (f64, f64) {
242+
let mut item:f64=0.0;
243+
let mut result_pi: f64 = 0.0;
244+
let mut result_tau: f64 = 0.0;
245+
// I 1 1 1 2 2 3
246+
// J 1 2 3 3 9 7
247+
let pi_2:f64 = pi*pi;
248+
let tau_2:f64=tau*tau;
249+
let tau_3:f64=tau_2*tau;
250+
let tau_6:f64=tau_3*tau_3;
251+
item = IJn[0].2 * pi*tau;
252+
result_pi += item;
253+
result_tau += item;
254+
item = IJn[1].2 * pi*tau_2;
255+
result_pi += item;
256+
result_tau += 2.0*item;
257+
item = IJn[2].2 * pi*tau_3;
258+
result_pi += item;
259+
result_tau += 3.0*item;
260+
item = IJn[3].2 * pi_2*tau_3;
261+
result_pi += 2.0*item;
262+
result_tau += 3.0*item;
263+
item = IJn[4].2 * pi_2*tau_6*tau_3;
264+
result_pi += 2.0*item;
265+
result_tau += 9.0*item;
266+
item = IJn[5].2 * pi_2*pi*tau_6*tau;
267+
result_pi += 3.0*item;
268+
result_tau += 7.0*item;
269+
(result_pi/pi, result_tau/tau)
270+
}

src/r5/region5_pT.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ pub fn pT2u_reg5(p: f64, T: f64) -> f64 {
2626
pub fn pT2s_reg5(p: f64, T: f64) -> f64 {
2727
let pi: f64 = p / r5Pstar;
2828
let tau: f64 = r5Tstar / T;
29+
2930
let (sum_gammar, sum_gammar_tau) = polys_0_j_powi(pi, tau, &IJn);
31+
32+
//let (sum_gammar, sum_gammar_tau) = gammar_pi_tau_reg5(pi, tau);
3033
//let sum_gammar=poly_powi(pi, tau, &IJn);
3134
//let sum_gammar_tau = poly_j_powi(pi, tau, &IJn);
35+
3236
let a: f64 = tau * (gamma0_tau_reg5(tau) + sum_gammar_tau) - (gamma0_reg5(pi, tau) + sum_gammar);
3337
RGAS_WATER * a
3438
}

0 commit comments

Comments
 (0)