+ if (_random) {
+ // Keep the new Cd within +- 10% of the current Cd to avoid a fluctuating value
+ double cd_min = _cd * 0.9;
+ double cd_max = _cd * 1.1;
+
+ // Randomize Cd by +- a certain percentage of the initial Cd
+ _cd = _init_cd * (1 - _cd_randomness + 2 * _cd_randomness * sg_random());
+
+ if (_cd < cd_min) _cd = cd_min;
+ if (_cd > cd_max) _cd = cd_max;
+ }