UltraScan III
us_solute.cpp
Go to the documentation of this file.
1 
3 #include "us_solute.h"
4 #include "us_math2.h"
5 
6 US_Solute::US_Solute( double s0, double k0, double c0,
7  double v0, double d0 )
8 {
9  s = s0;
10  k = k0;
11  c = c0;
12  v = v0;
13  d = d0;
14 }
15 
16 void US_Solute::init_solutes( double s_min, double s_max, int s_res,
17  double ff0_min, double ff0_max, int ff0_res,
18  int grid_reps, double cnstff0,
19  QList< QVector< US_Solute > >& solute_list )
20 {
21  if ( grid_reps < 1 ) grid_reps = 1;
22 
23  int nprs = qMax( 1, ( ( s_res / grid_reps ) - 1 ) );
24  int nprk = qMax( 1, ( ( ff0_res / grid_reps ) - 1 ) );
25  double s_step = fabs( s_max - s_min ) / (double)nprs;
26  double ff0_step = fabs( ff0_max - ff0_min ) / (double)nprk;
27  s_step = ( s_step > 0.0 ) ? s_step : ( s_min * 1.001 );
28  ff0_step = ( ff0_step > 0.0 ) ? ff0_step : ( ff0_min * 1.001 );
29  double s_grid = s_step / grid_reps;
30  double ff0_grid = ff0_step / grid_reps;
31 
32  // Allow a 1% overscan
33  s_max += 0.01 * s_step;
34  ff0_max += 0.01 * ff0_step;
35 
36  solute_list.reserve( sq( grid_reps ) );
37 
38  // Generate solutes for each grid repetition
39  for ( int i = 0; i < grid_reps; i++ )
40  {
41  for ( int j = 0; j < grid_reps; j++ )
42  {
43  solute_list << create_solutes(
44  s_min + s_grid * i, s_max, s_step,
45  ff0_min + ff0_grid * j, ff0_max, ff0_step,
46  cnstff0 );
47  }
48  }
49 }
50 
51 QVector< US_Solute > US_Solute::create_solutes(
52  double s_min, double s_max, double s_step,
53  double ff0_min, double ff0_max, double ff0_step,
54  double cnstff0 )
55 {
56  QVector< US_Solute > solute_vector;
57  double off0 = cnstff0;
58  double ovbar = 0.0;
59 
60  for ( double ff0 = ff0_min; ff0 <= ff0_max; ff0 += ff0_step )
61  {
62  if ( cnstff0 > 0.0 )
63  ovbar = ff0;
64  else
65  off0 = ff0;
66 
67  for ( double s = s_min; s <= s_max; s += s_step )
68  {
69  // Omit s values close to zero.
70  if ( s >= -1.0e-14 && s <= 1.0e-14 ) continue;
71 
72  solute_vector << US_Solute( s, off0, 0.0, ovbar );
73  }
74  }
75 
76  return solute_vector;
77 }
78 
79