示例#1
0
def CRIV_distrib(param,
                 criv='CRIV.csv',
                 param_distrib='param_distrib.csv',
                 sutra_inp_table='param_table.csv',
                 sutra_inp_file='param.txt',
                 q_riv='river_budget.txt',
                 aq_head='head_cell_aq.csv',
                 criv_value=os.path.join('output', 'CRIV_distrib.csv')):
    #---  Geometry - User input
    ct = param['ct']  # cell thickness [m]
    cw = param['cw']  # cell width [m]
    w = param['w']  # river width [m]
    d = param['d']  # river depth [m]
    a = param['a']  # bank angle [°]
    m = param['m']  #riverbed thikness [m]
    s1 = 2.  # (cw)/100. # general mesh element size [m]
    s2 = 0.2  #(cw)/100. # river mesh element size [m]

    #---  Geometry - Model input
    cw = cw * 3.
    d = d + 1.
    #---   Hydrodynamic properties
    anis = param['anis']  #anisotropy = Kh/Kv
    Kh = param['kh']  #Permeability in [L^2]  1m/s = 10^-7m^2
    Khb = param['khb']  #riverbed horizontal permeability [L^2]
    Kh = Kh * 1e-7
    Khb = Khb * 1e-7
    if m == 0:
        Khb = Kh

    if m == 0:
        m = ct / 20.

    Kvb = Khb
    #----- Flow Boundary conditions
    h_riv = (ct - 1)  # river head
    h_left = np.arange(h_riv - 1, h_riv + 1, 1)  # left head
    #----- Calc Xfar (need to be 0 in this operation)
    calcXfar = 0
    #----- Gen parameter distribution
    # number of random generation
    N = 500
    ct_sd = param['ct_sd']
    cw_sd = param['cw_sd']
    w_sd = param['w_sd']
    d_sd = param['d_sd']
    a_sd = param['a_sd']
    m_sd = param['m_sd']
    anis_sd = param['anis_sd']
    kh_sd = param['kh_sd']
    khb_sd = param['khb_sd']
    ct_distrib = np.random.normal(ct, ct_sd, N)
    cw_distrib = np.random.normal(cw, cw_sd, N)
    w_distrib = np.random.normal(w, w_sd, N)
    d_distrib = np.random.normal(d, d_sd, N)
    a_distrib = np.random.normal(a, a_sd, N)
    m_distrib = np.random.normal(m, m_sd, N)
    anis_distrib = np.random.normal(np.log10(anis), np.log10(anis_sd), N)
    anis_distrib = 10**(anis_distrib)
    kh_distrib = np.random.normal(np.log10(Kh), np.log10(kh_sd), N)
    kh_distrib = 10**(kh_distrib)
    khb_distrib = np.random.normal(np.log10(Khb), np.log10(khb_sd), N)
    khb_distrib = 10**(khb_distrib)
    output = np.column_stack(
        (ct_distrib.flatten(), cw_distrib.flatten(), w_distrib.flatten(),
         d_distrib.flatten(), a_distrib.flatten(), m_distrib.flatten(),
         anis_distrib.flatten(), kh_distrib.flatten(), khb_distrib.flatten()))
    np.savetxt(param_distrib, output, delimiter=' ', fmt='%1.1e')
    #tested parameter
    Param = h_left
    #output file
    param_output = criv
    conceptual = open(param_output, "w+")
    conceptual.close
    # clear file if existing
    #ccriv = open(criv_value, "w+")
    #ccriv.close
    with open(param_distrib, 'r') as param_gen:
        param_gen = csv.reader(param_gen, delimiter=' ')
        for row in param_gen:
            try:
                with open(sutra_inp_table, 'w') as output:
                    #write table for each value of tested parameter
                    param_table = csv.writer(output,
                                             delimiter=' ',
                                             lineterminator='\n')
                    for i in Param:
                        param_table.writerow((\
                        round(float(row[0]),0), round(float(row[1])*3,0), round(float(row[2]),0), round(float(row[3])+1,0),
                        round(float(row[4]),0), round(float(row[5]),0), float(s1), float(s2),
                        float(row[6]), float(row[7]), float(row[8]),float(row[8]),
                        float(i),float(h_riv),calcXfar ))

                with open(sutra_inp_table) as csv_data:
                    reader = csv.reader(csv_data)
                    rows = [row for row in reader if row]
                    for row in rows:
                        row = row
                        lis = [x.split() for x in row]
                        with open(sutra_inp_file, 'w') as output:
                            for x in zip(*lis):
                                for y in x:
                                    output.write(y + '\n')
                        xsection_rivaq.gen_mesh()
                        break
                    for row in rows:
                        row = row
                        lis = [x.split() for x in row]
                        with open(sutra_inp_file, 'w') as output:
                            for x in zip(*lis):
                                for y in x:
                                    output.write(y + '\n')
                        xsection_rivaq.run()
                        with open(param_output, 'a') as output:
                            with open(sutra_inp_file, 'r') as input_parameter:
                                ct = float(
                                    input_parameter.readline().split()[0])
                                cw = float(
                                    input_parameter.readline().split()[0])
                                w = float(
                                    input_parameter.readline().split()[0])
                                d = float(
                                    input_parameter.readline().split()[0])
                                a = float(
                                    input_parameter.readline().split()[0])
                                m = float(
                                    input_parameter.readline().split()[0])
                                s1 = float(
                                    input_parameter.readline().split()[0])
                                s2 = float(
                                    input_parameter.readline().split()[0])
                                anis = float(
                                    input_parameter.readline().split()[0])
                                Kh = float(
                                    input_parameter.readline().split()[0])
                                Khb = float(
                                    input_parameter.readline().split()[0])
                                Kvb = float(
                                    input_parameter.readline().split()[0])
                                h_left = float(
                                    input_parameter.readline().split()[0])
                                h_riv = float(
                                    input_parameter.readline().split()[0])
                            parameter = csv.writer(output,
                                                   delimiter=' ',
                                                   lineterminator='\n')
                            flow = np.loadtxt(q_riv)
                            TOTAL_FLOW = float(flow)
                            cell_head = np.loadtxt(aq_head)
                            cell_head = float(cell_head)
                            parameter.writerow((TOTAL_FLOW, cell_head - h_riv))
                    data1 = np.genfromtxt(criv,
                                          dtype=[('Q', float),
                                                 ('param', float)],
                                          delimiter=' ')
                    Q = data1['Q']
                    param = data1['param']
                    #stat
                    x = param[:, np.newaxis]
                    y = Q
                    a, _, _, _ = np.linalg.lstsq(x, y)
                    CRIV = (float(-a))
                    criv_file = open(criv_value, "a")
                    criv_file.write('' + str(CRIV) + '\n')
                    criv_file.close()
            except:
                print('error')
示例#2
0
def compute_Xfar(param,
                 xfar='./CRIV.csv',
                 sutra_inp_table='param_table.csv',
                 sutra_inp_file='param.txt',
                 q_riv='river_budget.txt',
                 aq_head='head_cell_aq.csv',
                 calc_xfar='xfar.csv',
                 plot=os.path.join('..', 'output', 'plot_xfar.png')):
    #---  Geometry - User input
    ct = param['ct']  # cell thickness [m]
    w = param['w']  # river width [m]
    d = param['d']  # river depth [m]
    a = param['a']  # bank angle [°]
    m = param['m']  #riverbed thikness [m]
    dh = param['dh']

    #---  Geometry - Model input
    mw = w * 30  # model width is 30 times river width [m]
    d = d + 1.
    #---mesh element size [m]
    s1 = 1.  # general mesh element size [m]
    s2 = 0.2  # river mesh element size [m]
    #---   Hydrodynamic properties
    anis = param['anis']  #anisotropy = Kh/Kv
    Kh = param['kh']  #Permeability in [L^2]  1m/s = 10^-7m^2
    Khb = param['khb']  #riverbed horizontal permeability [L^2]
    Kh = Kh * 1e-7
    Khb = Khb * 1e-7
    if m == 0:
        Khb = Kh

    if m == 0:
        m = ct / 20.

    Kvb = Khb
    #----- Flow Boundary conditions
    r4 = (mw / 2) - (w / 2)
    h_riv = (ct - 1)  # river head
    h_left = h_riv + (r4 * (dh / 100.))  #
    #----- Calc Xfar (need to be 1 in this operation)
    calcXfar = 1.

    with open(sutra_inp_table, 'w') as output:
        param_table = csv.writer(
            output, delimiter=' ', lineterminator='\n'
        )  #write table for each value of tested parameter
        param_table.writerow((\
        float(ct), float(mw), float(w), float(d),
        float(a), float(m), float(s1), float(s2),
        float(anis), float(Kh), float(Khb), float(Kvb),
        float(h_left),float(h_riv), float(calcXfar) ))
    with open(sutra_inp_table) as csv_data:
        reader = csv.reader(csv_data)
        rows = [row for row in reader if row]
        for row in rows:
            row = row
            lis = [x.split() for x in row]
            with open(sutra_inp_file, 'w') as output:
                for x in zip(*lis):
                    for y in x:
                        output.write(y + '\n')
            xsection_rivaq.gen_mesh()
            xsection_rivaq.run()

    data = np.genfromtxt(calc_xfar,
                         dtype=[('d', float), ('comp_x', float)],
                         delimiter=' ')
    d = data['d']
    comp_x = data['comp_x']
    x = d * (mw / 2)
    y = comp_x
    ylabel(' x component [%]', fontsize=17)
    xlabel(' Distance from river\'s center [m]', fontsize=17)
    grid(True)
    plt.plot(x, y, 'bo')
    savefig(plot)
    plt.close()
示例#3
0
def compute_CRIV(param,
                 criv='CRIV.csv',
                 sutra_inp_table='param_table.csv',
                 sutra_inp_file='param.txt',
                 q_riv='river_budget.txt',
                 aq_head='head_cell_aq.csv'):
    #---  Geometry - User input
    ct = param['ct']  # cell thickness [m]
    cw = param['cw']  # cell width [m]
    w = param['w']  # river width [m]
    d = param['d']  # river depth [m]
    a = param['a']  # bank angle [°]
    m = param['m']  #riverbed thikness [m]
    s1 = min(ct / 30., cw / 30.)  # general mesh element size [m]
    s2 = max(0.1, min(m / 5.,
                      cw / 20.))  #(cw)/100. # river mesh element size [m]

    #---  Geometry - Model input
    cw = cw * 3.
    d = d + 1.
    #---   Hydrodynamic properties
    anis = param['anis']  #anisotropy = Kh/Kv
    Kh = param[
        'kh'] * 1e-7  #Permeability in [m^2] (k [m^2] = 10^(-7) * K [m/s])
    Khb = param[
        'khb'] * 1e-7  #riverbed horizontal permeability [m^2]  (k [m^2] = 10^(-7) * K [m/s])
    if m == 0:
        Khb = Kh

    if m == 0:  # no streambed
        # set streambed thickness to a minimum value.
        # will have no effect since in this case we set Kvb = Kh
        m = ct / 20.

    Kvb = Khb
    #----- Flow Boundary conditions
    h_riv = (ct - 1)  # river head
    h_left = np.arange(h_riv - 5, h_riv + 5.5, 0.5)  # left head
    #----- Calc Xfar (need to be 0 in this operation)
    calcXfar = 0
    #tested parameter
    Param = h_left
    #output file
    param_output = criv
    conceptual = open(param_output, "w+")
    conceptual.close

    with open(sutra_inp_table, 'w') as output:
        #write table for each value of tested parameter
        param_table = csv.writer(output, delimiter=' ', lineterminator='\n')
        for i in Param:
            param_table.writerow((\
            float(ct), float(cw), float(w), float(d),
            float(a), float(m), float(s1), float(s2),
            float(anis), float(Kh), float(Khb), float(Kvb),
            float(i),float(h_riv),calcXfar ))

    with open(sutra_inp_table) as csv_data:
        reader = csv.reader(csv_data)
        rows = [row for row in reader if row]
        for row in rows:
            row = row
            lis = [x.split() for x in row]
            with open(sutra_inp_file, 'w') as output:
                for x in zip(*lis):
                    for y in x:
                        output.write(y + '\n')
            xsection_rivaq.gen_mesh()
            break
        for row in rows:
            row = row
            lis = [x.split() for x in row]
            with open(sutra_inp_file, 'w') as output:
                for x in zip(*lis):
                    for y in x:
                        output.write(y + '\n')
            xsection_rivaq.run()
            with open(param_output, 'a') as output:
                with open(sutra_inp_file, 'r') as input_parameter:
                    ct = float(input_parameter.readline().split()[0])
                    cw = float(input_parameter.readline().split()[0])
                    w = float(input_parameter.readline().split()[0])
                    d = float(input_parameter.readline().split()[0])
                    a = float(input_parameter.readline().split()[0])
                    m = float(input_parameter.readline().split()[0])
                    s1 = float(input_parameter.readline().split()[0])
                    s2 = float(input_parameter.readline().split()[0])
                    anis = float(input_parameter.readline().split()[0])
                    Kh = float(input_parameter.readline().split()[0])
                    Khb = float(input_parameter.readline().split()[0])
                    Kvb = float(input_parameter.readline().split()[0])
                    h_left = float(input_parameter.readline().split()[0])
                    h_riv = float(input_parameter.readline().split()[0])
                parameter = csv.writer(output,
                                       delimiter=' ',
                                       lineterminator='\n')
                flow = np.loadtxt(q_riv)
                TOTAL_FLOW = float(flow)
                cell_head = np.loadtxt(aq_head)
                cell_head = float(cell_head)
                parameter.writerow((TOTAL_FLOW, cell_head - h_riv))
示例#4
0
def CRIV_distrib(param, criv = 'CRIV.csv', param_distrib = 'param_distrib.csv', sutra_inp_table = 'param_table.csv',  
	sutra_inp_file = 'param.txt', q_riv = 'river_budget.txt', aq_head = 'head_cell_aq.csv', 
	criv_value = os.path.join('output','CRIV_distrib.csv')):
	#---  Geometry - User input
	ct = param['ct'] # cell thickness [m]
	cw = param['cw'] # cell width [m]
	w = param['w'] # river width [m]
	d = param['d'] # river depth [m]
	a = param['a'] # bank angle [°]
	m = param['m']#riverbed thikness [m]
	s1 = 2.# (cw)/100. # general mesh element size [m]
	s2 = 0.2#(cw)/100. # river mesh element size [m]

	#---  Geometry - Model input
	cw = cw * 3.
	d = d + 1.
	#---   Hydrodynamic properties 
	anis = param['anis']#anisotropy = Kh/Kv
	Kh = param['kh']  #Permeability in [L^2]  1m/s = 10^-7m^2      
	Khb = param['khb'] #riverbed horizontal permeability [L^2]
	Kh = Kh * 1e-7 
	Khb = Khb * 1e-7 
	if m == 0:
		Khb = Kh

	if m == 0:
		m = ct/20. 

	Kvb = Khb 
	#----- Flow Boundary conditions 
	h_riv = (ct - 1) # river head
	h_left = np.arange(h_riv - 1, h_riv + 1, 1) # left head 
	#----- Calc Xfar (need to be 0 in this operation) 
        calcXfar =  0
        #----- Gen parameter distribution
	# number of random generation
        N = 500
	ct_sd = param['ct_sd']
	cw_sd = param['cw_sd']
	w_sd = param['w_sd']
	d_sd = param['d_sd']
	a_sd = param['a_sd']
	m_sd = param['m_sd']
	anis_sd = param['anis_sd']
	kh_sd = param['kh_sd']
	khb_sd = param['khb_sd']
	ct_distrib = np.random.normal(ct, ct_sd, N)
	cw_distrib = np.random.normal(cw, cw_sd, N)
	w_distrib = np.random.normal(w, w_sd, N)
	d_distrib = np.random.normal(d, d_sd, N)
	a_distrib = np.random.normal(a, a_sd, N)
	m_distrib = np.random.normal(m, m_sd, N)
	anis_distrib = np.random.normal(np.log10(anis), np.log10(anis_sd), N)
	anis_distrib = 10**(anis_distrib)
	kh_distrib = np.random.normal(np.log10(Kh), np.log10(kh_sd), N)
	kh_distrib = 10**(kh_distrib)
	khb_distrib = np.random.normal(np.log10(Khb), np.log10(khb_sd), N)
	khb_distrib = 10**(khb_distrib)
	output = np.column_stack((ct_distrib.flatten(),cw_distrib.flatten(),w_distrib.flatten()
	                          ,d_distrib.flatten(),a_distrib.flatten(),m_distrib.flatten()
				  ,anis_distrib.flatten(),kh_distrib.flatten(),khb_distrib.flatten()))
	np.savetxt(param_distrib,output,delimiter=' ', fmt='%1.1e')
        #tested parameter
	Param = h_left     
	#output file
	param_output = criv
	conceptual = open(param_output, "w+")
	conceptual.close
	# clear file if existing
	#ccriv = open(criv_value, "w+")
	#ccriv.close
	with open(param_distrib,'r') as param_gen:  
	    param_gen = csv.reader(param_gen, delimiter = ' ')
	    for row in param_gen:
		try:
		    with open(sutra_inp_table,'w') as output:
			    #write table for each value of tested parameter
			    param_table = csv.writer(output, delimiter = ' ', lineterminator = '\n')  
			    for i in Param:
				    param_table.writerow((\
				    round(float(row[0]),0), round(float(row[1])*3,0), round(float(row[2]),0), round(float(row[3])+1,0),
				    round(float(row[4]),0), round(float(row[5]),0), float(s1), float(s2),
				    float(row[6]), float(row[7]), float(row[8]),float(row[8]),
				    float(i),float(h_riv),calcXfar )) 

		    with open(sutra_inp_table) as csv_data:
			    reader = csv.reader(csv_data)
			    rows = [row for row in reader if row]
			    for row in rows:
				    row = row
				    lis=[x.split() for x in row]
				    with open(sutra_inp_file,'w') as output:
					    for x in zip(*lis):
						    for y in x:
							    output.write(y+'\n')
				    xsection_rivaq.gen_mesh()
				    break
			    for row in rows:
				    row = row
				    lis=[x.split() for x in row]
				    with open(sutra_inp_file,'w') as output:
					    for x in zip(*lis):
						    for y in x:
							    output.write(y+'\n')
				    xsection_rivaq.run() 
				    with open(param_output,'a') as output:
					    with open(sutra_inp_file,'r') as input_parameter:
						    ct = float( input_parameter.readline().split()[0] )
						    cw = float( input_parameter.readline().split()[0] )
						    w = float( input_parameter.readline().split()[0] )
						    d = float( input_parameter.readline().split()[0] )
						    a = float( input_parameter.readline().split()[0] )
						    m = float( input_parameter.readline().split()[0] )
						    s1 = float( input_parameter.readline().split()[0] )
						    s2 = float( input_parameter.readline().split()[0] )
						    anis = float( input_parameter.readline().split()[0] )
						    Kh = float( input_parameter.readline().split()[0] )
						    Khb = float( input_parameter.readline().split()[0] )
						    Kvb = float( input_parameter.readline().split()[0] )
						    h_left = float( input_parameter.readline().split()[0] )
						    h_riv = float( input_parameter.readline().split()[0] )
					    parameter = csv.writer(output, delimiter = ' ', lineterminator = '\n')
					    flow = np.loadtxt(q_riv)
					    TOTAL_FLOW = float(flow)
					    cell_head = np.loadtxt(aq_head)
					    cell_head = float(cell_head)
					    parameter.writerow((TOTAL_FLOW, cell_head-h_riv))
			    data1 = np.genfromtxt(criv, dtype=[('Q',float),('param',float)], delimiter = ' ')
			    Q = data1['Q']
			    param = data1['param']
			    #stat
			    x = param[:,np.newaxis]
			    y= Q
			    a, _, _, _ = np.linalg.lstsq(x, y)
			    CRIV = (float(-a))
			    criv_file = open(criv_value, "a")
			    criv_file.write(''+str(CRIV)+'\n')
			    criv_file.close()
		except:
		    print('error')
示例#5
0
def compute_Xfar(param, xfar = './CRIV.csv', sutra_inp_table = 'param_table.csv',  
	sutra_inp_file = 'param.txt', q_riv = 'river_budget.txt', aq_head = 'head_cell_aq.csv', 
	calc_xfar = 'xfar.csv', plot = os.path.join('..','output','plot_xfar.png')) :
	#---  Geometry - User input
	ct = param['ct'] # cell thickness [m]
	w = param['w'] # river width [m]
	d = param['d'] # river depth [m]
	a = param['a'] # bank angle [°]
	m = param['m']#riverbed thikness [m]
	dh = param['dh']

	#---  Geometry - Model input
	mw = w*30 # model width is 30 times river width [m]
	d = d + 1.
	#---mesh element size [m]
	s1 = 1. # general mesh element size [m]
	s2 = 0.2  # river mesh element size [m]
	#---   Hydrodynamic properties 
	anis = param['anis']#anisotropy = Kh/Kv
	Kh = param['kh']  #Permeability in [L^2]  1m/s = 10^-7m^2      
	Khb = param['khb'] #riverbed horizontal permeability [L^2]
	Kh = Kh * 1e-7 
	Khb = Khb * 1e-7 
	if m == 0:
		Khb = Kh

	if m == 0:
		m = ct/20.  

	Kvb = Khb 
	#----- Flow Boundary conditions 
        r4 = (mw/2) - (w/2)
	h_riv = (ct - 1) # river head
	h_left = h_riv + (r4 * (dh/100.)) #  
	#----- Calc Xfar (need to be 1 in this operation) 
        calcXfar =  1.


	with open(sutra_inp_table,'w') as output:
		param_table = csv.writer(output, delimiter = ' ', lineterminator = '\n') #write table for each value of tested parameter 
		param_table.writerow((\
		float(ct), float(mw), float(w), float(d),
		float(a), float(m), float(s1), float(s2),
		float(anis), float(Kh), float(Khb), float(Kvb),
		float(h_left),float(h_riv), float(calcXfar) ))
	with open(sutra_inp_table) as csv_data:
		reader = csv.reader(csv_data)
		rows = [row for row in reader if row]
		for row in rows:
			row = row
			lis=[x.split() for x in row]
			with open(sutra_inp_file,'w') as output:
				for x in zip(*lis):
					for y in x:
						output.write(y+'\n')
			xsection_rivaq.gen_mesh()
			xsection_rivaq.run() 

	data = np.genfromtxt(calc_xfar, dtype=[('d',float),('comp_x',float)], delimiter = ' ')
	d = data['d']
	comp_x = data['comp_x']
	x = d*(mw/2)
	y = comp_x
	ylabel(' x component [%]', fontsize =17 )
	xlabel(' Distance from river\'s center [m]', fontsize =17)
	grid(True)
	plt.plot(x, y, 'bo')
	savefig(plot)
	plt.close()
示例#6
0
def compute_CRIV(param, criv = 'CRIV.csv', sutra_inp_table = 'param_table.csv',  
	sutra_inp_file = 'param.txt', q_riv = 'river_budget.txt', aq_head = 'head_cell_aq.csv'):
	#---  Geometry - User input
	ct = param['ct'] # cell thickness [m]
	cw = param['cw'] # cell width [m]
	w = param['w'] # river width [m]
	d = param['d'] # river depth [m]
	a = param['a'] # bank angle [°]
	m = param['m']#riverbed thikness [m]
	s1 = min( ct/30., cw/30.) # general mesh element size [m]
	s2 = max(0.1, min( m/5., cw/20.)) #(cw)/100. # river mesh element size [m]

	#---  Geometry - Model input
	cw = cw * 3.
	d = d + 1.
	#---   Hydrodynamic properties 
	anis = param['anis']#anisotropy = Kh/Kv
	Kh = param['kh']*1e-7  #Permeability in [m^2] (k [m^2] = 10^(-7) * K [m/s])    
	Khb = param['khb']*1e-7 #riverbed horizontal permeability [m^2]  (k [m^2] = 10^(-7) * K [m/s])
	if m == 0:
		Khb = Kh

	if m == 0: # no streambed
	    	# set streambed thickness to a minimum value.
		# will have no effect since in this case we set Kvb = Kh
		m = ct/20.   

	Kvb = Khb 
	#----- Flow Boundary conditions 
	h_riv = (ct - 1) # river head
	h_left = np.arange(h_riv - 5, h_riv + 5.5, 0.5) # left head 
	#----- Calc Xfar (need to be 0 in this operation) 
        calcXfar =  0
	#tested parameter
	Param = h_left     
	#output file
	param_output = criv
	conceptual = open(param_output, "w+")
	conceptual.close

	with open(sutra_inp_table,'w') as output:
		#write table for each value of tested parameter
		param_table = csv.writer(output, delimiter = ' ', lineterminator = '\n')  
		for i in Param:
			param_table.writerow((\
			float(ct), float(cw), float(w), float(d),
			float(a), float(m), float(s1), float(s2),
			float(anis), float(Kh), float(Khb), float(Kvb),
			float(i),float(h_riv),calcXfar )) 

	with open(sutra_inp_table) as csv_data:
		reader = csv.reader(csv_data)
		rows = [row for row in reader if row]
		for row in rows:
			row = row
			lis=[x.split() for x in row]
			with open(sutra_inp_file,'w') as output:
				for x in zip(*lis):
					for y in x:
						output.write(y+'\n')
			xsection_rivaq.gen_mesh()
			break
		for row in rows:
			row = row
			lis=[x.split() for x in row]
			with open(sutra_inp_file,'w') as output:
				for x in zip(*lis):
					for y in x:
						output.write(y+'\n')
			xsection_rivaq.run() 
			with open(param_output,'a') as output:
				with open(sutra_inp_file,'r') as input_parameter:
					ct = float( input_parameter.readline().split()[0] )
					cw = float( input_parameter.readline().split()[0] )
					w = float( input_parameter.readline().split()[0] )
					d = float( input_parameter.readline().split()[0] )
					a = float( input_parameter.readline().split()[0] )
					m = float( input_parameter.readline().split()[0] )
					s1 = float( input_parameter.readline().split()[0] )
					s2 = float( input_parameter.readline().split()[0] )
					anis = float( input_parameter.readline().split()[0] )
					Kh = float( input_parameter.readline().split()[0] )
					Khb = float( input_parameter.readline().split()[0] )
					Kvb = float( input_parameter.readline().split()[0] )
					h_left = float( input_parameter.readline().split()[0] )
					h_riv = float( input_parameter.readline().split()[0] )
				parameter = csv.writer(output, delimiter = ' ', lineterminator = '\n')
				flow = np.loadtxt(q_riv)
				TOTAL_FLOW = float(flow)
				cell_head = np.loadtxt(aq_head)
				cell_head = float(cell_head)
				parameter.writerow((TOTAL_FLOW, cell_head-h_riv))