r"""
        Adds outflow boundary condition to the selected pores.

        Outflow condition simply means that the gradient of the solved
        quantity does not change, i.e. is 0.
13026
def set_outflow_BC(self, pores, mode='merge'):
        

        """
        # Hijack the parse_mode function to verify mode/pores argument
        mode = self._parse_mode(mode, allowed=['merge', 'overwrite', 'remove'],
                                single=True)
        pores = self._parse_indices(pores)
        # Calculating A[i,i] values to ensure the outflow condition
        network = self.project.network
        phase = self.project.phases()[self.settings['phase']]
        throats = network.find_neighbor_throats(pores=pores)
        C12 = network['throat.conns'][throats]
        P12 = phase[self.settings['pressure']][C12]
        gh = phase[self.settings['hydraulic_conductance']][throats]
        Q12 = -gh * np.diff(P12, axis=1).squeeze()
        Qp = np.zeros(self.Np)
        np.add.at(Qp, C12[:, 0], -Q12)
        np.add.at(Qp, C12[:, 1], Q12)
        # Store boundary values
        if ('pore.bc_outflow' not in self.keys()) or (mode == 'overwrite'):
            self['pore.bc_outflow'] = np.nan
        self['pore.bc_outflow'][pores] = Qp[pores]
1146068
def calculate_pore_diameter(self):
        
        self.pore_diameter, self.pore_closest_atom = pore_diameter(
            self.elements, self.coordinates)
        self.properties['pore_diameter'] = {
            'diameter': self.pore_diameter,
            'atom': int(self.pore_closest_atom),
        }
        return self.pore_diameter
1052754
def _Stichlmair_flood_f_and_jac(inputs, Vl, rhog, rhol, mug, voidage, 
                                specific_area, C1, C2, C3, H):
    '''
    '''
    Vg, dP_irr = float(inputs[0]), float(inputs[1])
    x0 = 1.0/H
    x1 = Vg*Vg
    x2 = voidage**(-4.65)
    x3 = specific_area*x2
    x4 = Vl*Vl*x3/g
    x5 = x4**0.333333333333333
    x6 = dP_irr*dP_irr
    x7 = H*H
    x8 = 1.0/x7
    x9 = g*g
    x10 = 1.0/x9
    x11 = rhol*rhol
    x12 = 1.0/x11
    x13 = x5*(20.0*x10*x12*x6*x8 + 1.0)
    x14 = 0.555*x13
    x15 = (voidage/(voidage - x14))**4.65
    x16 = 1.0/Vg
    x17 = 1.0/rhog
    x18 = voidage - 1.0
    x19 = 1.0/x18
    x20 = C1*mug*specific_area*x16*x17*x19
    x21 = 2.44948974278318*C2
    x22 = Vg*rhog/(mug*specific_area)
    x23 = x21*(-x18*x22)**-0.5
    x24 = 6.0*C3 - x20 + x23
    x25 = 1.0 - voidage 
    x26 = x14 + x25
    x27 = -x19*x26
    x28 = 2.0*C1*mug*specific_area*x16*x17/x25 + x21*(x22*x25)**-0.5
    x29 = 1.0/x24
    x30 = x28*x29
    x31 = x27**(-0.166666666666667*x30 + 0.666666666666667)
    x32 = x11*x7*x9
    x33 = 200.0*voidage
    x34 = 111.0*x13
    x35 = x33 - x34
    x36 = 1.0/x35
    x37 = -x33 + x34 + 200.0
    x38 = 1.0/x37
    x39 = 2.0*x20
    x40 = -4.0*x20 + x23 + x29*(-x23 + x39)*(x23 - x39)
    x41 = dP_irr*rhog*specific_area*x0*x1*x10*x12*x15*x2*x24*x31
    x42 = dP_irr*x10*x12*x4**0.666666666666667*x8
    
    F1, F2, dF1_dVg, dF2_dVg, dF1_dP_irr, dF2_dP_irr = (
            -dP_irr*x0 + 0.0208333333333333*rhog*specific_area*x1*x15*x2*x24*x31,
             x32/x6 - 20646.0*x36*x5 - x38*x5*(2960.0 - 740.0*x28*x29),
             0.00173611111111111*Vg*rhog*x15*x3*x31*(144.0*C3 - 12.0*x20 + 18.0*x23 + x40*log(x27)),
             x0*(430.125*x36*x41*x5 - 15.4166666666667*x38*x41*x5*(x30 - 4.0) - 1.0),
             -1.85*x16*x29*x40*x5/x26,
             3285600.0*x42*(-x30 + 4.0)*x38*x38- 91668240.0*x42*x36*x36 - 2.0*x32/(dP_irr*x6))
    
    return [F1, F2], [[dF1_dVg, dF2_dVg], [dF1_dP_irr, dF2_dP_irr]]
1259000
function() {
    var min = typeof this.options.start_value !== 'undefined' && this.min >= 0 ? this.options.start_value : this.min,
        start_value = this.round(min, 1);

    /* This is a boundary condition */
    if (this.min > 0 && start_value > this.min) {
      return 0;
    }

    if (this.min === this.max) {
      return 0;
    }

    return start_value;
  }
778035
def add_condition(self, observed_arr):
        '''
        
        '''
        condition_arr = self.__image_true_sampler.draw()
        return np.concatenate((observed_arr, condition_arr), axis=1)
1137521
def _Stichlmair_flood_f(inputs, Vl, rhog, rhol, mug, voidage, specific_area,
                        C1, C2, C3, H):
    '''
    '''
    Vg, dP_irr = float(inputs[0]), float(inputs[1])
    dp = 6.0*(1.0 - voidage)/specific_area
    Re = Vg*rhog*dp/mug
    f0 = C1/Re + C2/Re**0.5 + C3
    dP_dry = 0.75*f0*(1.0 - voidage)/voidage**4.65*rhog*H/dp*Vg*Vg
    c = (-C1/Re - 0.5*C2*Re**-0.5)/f0
    Frl = Vl*Vl*specific_area/(g*voidage**4.65)
    h0 = 0.555*Frl**(1/3.)
    hT = h0*(1.0 + 20.0*(dP_irr/H/rhol/g)**2)
    err1 = dP_dry/H*((1.0 - voidage + hT)/(1.0 - voidage))**((2.0 + c)/3.)*(voidage/(voidage-hT))**4.65 - dP_irr/H
    term = (dP_irr/(rhol*g*H))**2
    err2 = (1./term - 40.0*((2.0+c)/3.)*h0/(1.0 - voidage + h0*(1.0 + 20.0*term))
    - 186.0*h0/(voidage - h0*(1.0 + 20.0*term)))
    return err1, err2
170179
function(ctx, from, to, width, gradient) {

        var innerWidth = width - 4;
        var outerWidth = width;
        var buttFrom = g.point(from).move(to, -outerWidth / 2);
        var buttTo = g.point(to).move(from, -outerWidth / 2);

        ctx.beginPath();
        ctx.lineWidth = outerWidth;
        ctx.strokeStyle = 'rgba(0,0,0,0.6)';

        ctx.moveTo(from.x, from.y);
        ctx.lineTo(to.x, to.y);
        ctx.stroke();
        ctx.closePath();

        gradient.addColorStop(0.000, 'rgba(86, 170, 255, 1)');
        gradient.addColorStop(0.500, 'rgba(255, 255, 255, 1)');
        gradient.addColorStop(1.000, 'rgba(86, 170, 255, 1)');

        ctx.beginPath();
        ctx.lineWidth = innerWidth;
        ctx.strokeStyle = gradient;
        ctx.moveTo(from.x, from.y);

        ctx.lineTo(to.x, to.y);
        ctx.stroke();
        ctx.closePath();

        ctx.lineCap = "square";

        ctx.beginPath();
        ctx.lineWidth = innerWidth;
        ctx.strokeStyle = 'rgba(0,0,0,0.5)';
        ctx.moveTo(from.x, from.y);
        ctx.lineTo(buttFrom.x, buttFrom.y);
        ctx.stroke();
        ctx.closePath();

        ctx.beginPath();
        ctx.lineWidth = innerWidth;
        ctx.strokeStyle = 'rgba(0,0,0,0.5)';
        ctx.moveTo(to.x, to.y);
        ctx.lineTo(buttTo.x, buttTo.y);
        ctx.stroke();
        ctx.closePath();
    }
614097
function diffusionUpdate () {
    var row, col, ind
    var dum = conv2(u, coeffs)
    for (row = 0; row < height; ++row)
      for (col = 0; col < width; ++col) {
        ind = row * width + col
        un[ind] = u[ind] +  c4 * dum[ind]
        u[ind] = un[ind] // new becomes current
      }
    return u
  }
1122760
def getDampingIntegral(self):
        
        reservoir = self.getReservoir()
        density = self.getDensity()
        length = self.model.getSpatialStep()

        if self.solution.ndim == 1:
            nodes = self.model.getNumberOfNodes()
            radius = linspace(0, nodes * self.model.getSpatialStep(), nodes)
            integral = 2 * pi * sum((reservoir - 1.0) * density * radius * length)
        elif self.solution.ndim == 2:
            area = length ** 2
            integral = sum(sum((reservoir - 1.0) * density * area))

        return integral
794372
def _HuntFlowCondition(self, condition):
    """"""
    if condition == db.HuntFlowsCondition.UNSET:
      return "", []
    elif condition == db.HuntFlowsCondition.FAILED_FLOWS_ONLY:
      return ("AND flow_state = %s ",
              [int(rdf_flow_objects.Flow.FlowState.ERROR)])
    elif condition == db.HuntFlowsCondition.SUCCEEDED_FLOWS_ONLY:
      return ("AND flow_state = %s ",
              [int(rdf_flow_objects.Flow.FlowState.FINISHED)])
    elif condition == db.HuntFlowsCondition.COMPLETED_FLOWS_ONLY:
      return ("AND (flow_state = %s OR flow_state = %s) ", [
          int(rdf_flow_objects.Flow.FlowState.FINISHED),
          int(rdf_flow_objects.Flow.FlowState.ERROR)
      ])
    elif condition == db.HuntFlowsCondition.FLOWS_IN_PROGRESS_ONLY:
      return ("AND flow_state = %s ",
              [int(rdf_flow_objects.Flow.FlowState.RUNNING)])
    elif condition == db.HuntFlowsCondition.CRASHED_FLOWS_ONLY:
      return ("AND flow_state = %s ",
              [int(rdf_flow_objects.Flow.FlowState.CRASHED)])
    else:
      raise ValueError("Invalid condition value: %r" % condition)
54420
@Override
  public void sinkConfInit(FlowProcess<? extends Configuration> flowProcess,
      Tap<Configuration, RecordReader, OutputCollector> tap, Configuration conf) {
    conf.setBoolean("mapred.mapper.new-api", false);
    conf.setClass("mapred.output.format.class", CorcOutputFormat.class, OutputFormat.class);
    conf.setClass("mapreduce.job.output.key.class", NullWritable.class, Writable.class);
    conf.setClass("mapreduce.job.output.value.class", Corc.class, Writable.class);
  }
64946
def addDarkCurrent(self, slope, intercept=None, date=None, info='', error=None):
        '''
        
        '''
        date = _toDate(date)

        self._checkShape(slope)
        self._checkShape(intercept)

        d = self.coeffs['dark current']
        if intercept is None:
            data = slope
        else:
            data = (slope, intercept)
        d.insert(_insertDateIndex(date, d), [date, info, data, error])
277196
def rhochange(self):
        """"""

        self.lu, self.piv = sl.lu_factor(self.Z, self.rho)
        self.lu = np.asarray(self.lu, dtype=self.dtype)
735952
def draw(self):
        '''
        
        '''
        observed_arr = self.extract_conditions()
        conv_arr = self.inference(observed_arr)

        if self.__conditon_noise_sampler is not None:
            self.__conditon_noise_sampler.output_shape = conv_arr.shape
            noise_arr = self.__conditon_noise_sampler.generate()
            conv_arr += noise_arr

        deconv_arr = self.__deconvolution_model.inference(conv_arr)
        return np.concatenate((deconv_arr, observed_arr), axis=1)
288012
@Override
	public BarrierFunction createPhase1BarrierFunction(){
		
		final int dimPh1 = dim +1;
		ConvexMultivariateRealFunction[] inequalitiesPh1 = new ConvexMultivariateRealFunction[this.fi.length];
		for(int i=0; i<inequalitiesPh1.length; i++){
			
			final ConvexMultivariateRealFunction originalFi = this.fi[i];
			
			ConvexMultivariateRealFunction fi = new ConvexMultivariateRealFunction() {
				
				@Override
				public double value(double[] Y) {
					DoubleMatrix1D y = DoubleFactory1D.dense.make(Y);
					DoubleMatrix1D X = y.viewPart(0, dim);
					return originalFi.value(X.toArray()) - y.get(dimPh1-1);
				}
				
				@Override
				public double[] gradient(double[] Y) {
					DoubleMatrix1D y = DoubleFactory1D.dense.make(Y);
					DoubleMatrix1D X = y.viewPart(0, dim);
					DoubleMatrix1D origGrad = F1.make(originalFi.gradient(X.toArray()));
					DoubleMatrix1D ret = F1.make(1, -1);
					ret = F1.append(origGrad, ret);
					return ret.toArray();
				}
				
				@Override
				public double[][] hessian(double[] Y) {
					DoubleMatrix1D y = DoubleFactory1D.dense.make(Y);
					DoubleMatrix1D X = y.viewPart(0, dim);
					DoubleMatrix2D origHess;
					double[][] origFiHessX = originalFi.hessian(X.toArray());
					if(origFiHessX == FunctionsUtils.ZEROES_2D_ARRAY_PLACEHOLDER){
						return FunctionsUtils.ZEROES_2D_ARRAY_PLACEHOLDER;
					}else{
						origHess = F2.make(origFiHessX);
						DoubleMatrix2D[][] parts = new DoubleMatrix2D[][]{{origHess, null},{null,F2.make(1, 1)}};
						return F2.compose(parts).toArray();
					}
				}
				
				@Override
				public int getDim() {
					return dimPh1;
				}
			};
			inequalitiesPh1[i] = fi;
		}
		
		BarrierFunction bfPh1 = new LogarithmicBarrier(inequalitiesPh1, dimPh1);
		return bfPh1;
	}
47709
def optimise_xy(xy, *args):
    """"""
    z, elements, coordinates = args
    window_com = np.array([xy[0], xy[1], z])
    return -pore_diameter(elements, coordinates, com=window_com)[0]
407736
function booleanEnvTrace(condition) {
    var conditionObj = parseCondition(condition);

    if (conditionObj.negate)
      return traceCondition(conditionalComplement(condition), false);
    else
      return traceCondition(condition, true);
  }