# -*- coding: cp1250 -*-
import math
import vypocet_2v0
import csv
import numpy as np
import random

## zápis nadpisu a jednotek do souboru
zapis = open('integralni_metoda_katal_pn16.csv','wb')
nadpisy = ('Temp','Temp_mont','material_sroubu','tloustka_sroubu','material_tesneni','tlakova_zkouska',
           'pn','g0','P','B','Dstp','Dvtp','dbmin','C','g1','deltab','db','e','A','w','h','v','material_priruby',
           'tloustka_priruby','material_plaste','tloustka_plaste',
           'Rp02t_sroubu','Rm_sroubu','A_sroubu','oznaceni_sroubu','materialovy_ekvivalent_sroubu',
           'norma_sroubu','Rp02t_priruba','Rm_priruba','A_priruba','oznaceni_priruby',
           'materialovy_ekvivalent_priruby','norma_priruby','typ_tesneni','m','y','w_min',
           'beta_2','Rp02t_plaste','Rm_plaste','A_plaste','oznaceni_plaste','materialovy_ekvivalent_plaste',
           'norma_plaste','f_priruba','f_sroubu','f_sroubu_mont','f_plaste','priruba_pevnost',
           'typ_tesneni','b0','b','G','H','HG','WA','Wop','ABmin','AB','HD','HT','hD','hG','hT','W','MA',
           'Mop','CF','K','l0','betaT','betaU','betaY','M_montaz','M_provoz','betaF','betaV','fi','Lambda','sigmaH_montaz','sigmaH_provoz','sigmar_montaz','sigmar_provoz','sigmaTHETA_montaz','sigmaTHETA_provoz',
           'podminka_priruba','podminka_tloustka_sroubu','podminka_tloustka_priruby','podminka_tloustka_plaste',
           'podminka_vstupni_hodnoty','podminka_plochy_sroubu','podminka_priruba_montaz','podminka_priruba_provoz',
           'k_sigmaH_montaz','k_sigmar_montaz','k_sigmaTHETA_montaz','0_5_k_sigmaH_montaz_sigmar_montaz','0_5_k_sigmaH_montaz_sigmaTHETA_montaz',
           'k_sigmaH_provoz','k_sigmar_provoz','k_sigmaTHETA_provoz','0_5_k_sigmaH_provoz_sigmar_provoz','0_5_k_sigmaH_provoz_sigmaTHETA_provoz',) # nadpis proměnných


jednotky = ('°C','°C','-','mm','-','-','bar','mm','MPa','mm','mm','mm','mm','mm','mm','mm','mm','mm','mm','mm','mm','mm',
            '-','mm','-','mm',
            'MPa','MPa','%','-','-','-','MPa','MPa','%','-','-','-','-','-','MPa','mm','-','MPa',
            'MPa','%','-','-','-','MPa','MPa','MPa','MPa','-','-','mm','mm','N','N','N',
            'N','N','mm2','mm2','N','N','mm','mm','mm','N','Nmm','Nmm','mm','-','mm','-','-','-',
            'Nmm','Nmm','-','-','-','-','MPa','MPa','MPa','MPa','MPa','MPa','-','-','-','-','-','-','-','-',
            '-','-','-','-','-','-','-','-','-','-') # jednotky

for nazvy_nadpisu in nadpisy:
    zapis.write('%s;' % str(nazvy_nadpisu))
zapis.write('\n')
for nazvy_jednotek in jednotky:
    zapis.write('%s;' % str(nazvy_jednotek))
zapis.write('\n')

##celkem_opakovani = 10000
##for opakovani in xrange(1,celkem_opakovani):
##    ## vstupní proměnné - randomizace proměnných
##    Temp=np.random.uniform(20.,350.) # Temp - pracovní teplota
##    Temp_mont=np.random.uniform(20.,350.) # Temp - pracovní teplota
##    material_sroubu = random.sample(["C35E+QT","C35E+N","25CrMo4+QT","42CrMo4+QT","42CrMo5-6+QT","40CrMoV4-6+QT"],1)[0]
##    tloustka_sroubu = np.random.uniform(0.,60.)
##    material_tesneni = random.sample(["pryz_bez_tkaniva_pod_75","pryz_bez_podilu_azbest_vlakna_pod_75",
##                                      "pryz_bez_tkaniva_nad_75","pryz_bez_podilu_azbest_vlakna_nad_75",
##                                      "azbest_s_pojivem_tl3.2","azbest_s_pojivem_tl1.6","azbest_s_pojivem_tl0.8",
##                                      "pryz_s_bavlnenou_vlozkou","pryz_s_azbest_tkanivem_trivrstvy",
##                                      "pryz_s_azbest_tkanivem_dvouvrstvy","pryz_s_azbest_tkanivem_jednovrstvy",
##                                      "rostlina_vlakna","spir_vinute_kovove_uhlikova",
##                                      "spir_vinute_kovove_korozivzdorna/monel","vlnity_kov_mekky_hlinik",
##                                      "vlnity_kov_mekka_med/mosaz","vlnity_kov_zelezo/mekka_ocel",
##                                      "vlnity_kov_monel/ocel4-6%chromu","vlnity_kov_korozivzdorna",
##                                      "vlnity_kov_obal_mekky_hlinik","vlnity_kov_obal_mekka_med/mosaz",
##                                      "vlnity_kov_obal_zelezo/mekka_ocel","vlnity_kov_obal_monel/ocel4-6%chromu",
##                                      "vlnity_kov_obal_korozivzdorna","ploche_kovove_mekky_hlinik",
##                                      "ploche_kovove_mekka_med/mosaz","ploche_kovove_zelezo/mekka_ocel",
##                                      "ploche_kovove_monel","ploche_kovove_ocel4-6%chromu",
##                                      "ploche_kovove_korozivzdorna","hrebenove_mekky_hlinik",
##                                      "hrebenove_mekka_med/mosaz","hrebenove_zelezo/mekka_ocel",
##                                      "hrebenove_monel/ocel4-6%chromu","hrebenove_korozivzdorna",
##                                      "plne_ploche_kovove_mekka_med/mosaz","plne_ploche_kovove_zelezo/mekka_ocel",
##                                      "plne_ploche_kovove_monel","plne_ploche_kovove_ocel4-6%chromu",
##                                      "plne_ploche_kovove_korozivzdorna","prstencove_zelezo/mekka_ocel",
##                                      "prstencove_monel/ocel4-6%chromu","prstencove_korozivzdorna",
##                                      "pryz_0kr_pod_75","pryz_0kr_nad_75","pryz_pravouhle_pod_75",
##                                      "pryz_pravouhle_nad_75","pryz_T_pod_75","pryz_T_nad_75"],1)[0]
##    tlakova_zkouska = random.sample([True, False],1)[0]


d3=[74.,92.,105.,131.,156.,184.,235.,292.,344.,390.,445.,490.,548.,652.,755.,855.,955.,1058.,1262.,1465.,1668.,] # d3
b=[18.,18.,20.,20.,22.,22.,24.,26.,28.,30.,32.,34.,36.,40.,40.,41.,48.,59.,78.,84.,102.,] # b
f=[3.,3.,3.,3.,3.,3.,3.,3.,4.,4.,4.,4.,4.,5.,5.,5.,5.,5.,5.,5.,5.,] # f
n=[4.,8.,8.,8.,8.,8.,12.,12.,12.,16.,16.,20.,20.,20.,24.,24.,28.,28.,32.,36.,40.,] # n
Temp=[20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,] # Temp=20
Temp_mont=[20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,20.,] # Temp=20
material_sroubu=["25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT","25CrMo4+QT",]
material_priruby=["16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3","16Mo3"]
material_plaste=["P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH","P235GH",]

material_tesneni=["pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou",
                  "pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou",
                  "pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou","pryz_s_bavlnenou_vlozkou",]

tlakova_zkouska=[False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,]
tloustka_sroubu= [18.,18.,18.,18.,18.,22.,22.,26.,26.,26.,30.,30.,33.,36.,36.,39.,39.,42.,48.,48.,56.,] #d2
g0=[2.9,2.9,3.2,3.6,4.,4.5,6.3,6.3,7.1,8.,8.,8.,8.,10.,10.,12.5,12.5,12.5,14.2,16.,17.5,]                  #s ??? 
P=[1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,]                                    # ??? 
B=[50.,65.,80.,100.,125.,150.,200.,250.,300.,350.,400.,450.,500.,600.,700.,800.,900.,1000.,1200.,1400.,1600.,] # DN
Dvtp=[102.,122.,138.,158.,188.,212.,268.,320.,378.,438.,490.,550.,610.,725.,795.,900.,1000.,1115.,1330.,1530.,1750.,]  #  d4       !!!!!!!!
Dstp=[92.,112.,128.,148.,178.,202.,258.,310.,368.,428.,480.,540.,600.,715.,785.,890.,990.,1105.,1320.,1520.,1740.,]     # d4-10   !!!!!!!!
C=[125.,145.,160.,180.,210.,240.,295.,355.,410.,470.,525.,585.,650.,770.,840.,950.,1050.,1170.,1390.,1590.,1820.,] #k
db=[18.,18.,18.,18.,18.,22.,22.,26.,26.,26.,30.,30.,33.,36.,36.,39.,39.,42.,48.,48.,56.,]       #d2
A=[165.,185.,200.,220.,250.,285.,340.,405.,460.,520.,580.,640.,715.,840.,910.,1025.,1125.,1255.,1485.,1685.,1930.,] # D

h=[8.,10.,10.,12.,12.,12.,16.,16.,16.,16.,16.,16.,16.,18.,18.,20.,20.,22.,30.,30.,35.,] # h2 
v=[0.28,0.28,0.28,0.28,0.28,0.28,0.28,0.28,0.28,0.28,0.28,0.28,0.28,0.28,0.28,0.28,0.28,0.28,0.28,0.28,0.28,] # v Poissonuv poměr (pro ocel cca 0.28)

pn_=[16.,16.,16.,16.,16.,16.,16.,16.,16.,16.,16.,16.,16.,16.,16.,16.,16.,16.,16.,16.,16.,]# PN

Rp02t_priruba_=[295.,295.,295.,295.,295.,295.,295.,295.,295.,295.,295.,295.,295.,285.,285.,285.,285.,285.,275.,275.,250.] # hodnoty z ulozeni_dat_katal_pn16
ft=[(Rp02t_priruba_[0]/1.9),
   (Rp02t_priruba_[1]/1.9),
   (Rp02t_priruba_[2]/1.9),
   (Rp02t_priruba_[3]/1.9),
   (Rp02t_priruba_[4]/1.9),
   (Rp02t_priruba_[5]/1.9),
   (Rp02t_priruba_[6]/1.9),
   (Rp02t_priruba_[7]/1.9),
   (Rp02t_priruba_[8]/1.9),
   (Rp02t_priruba_[9]/1.9),
   (Rp02t_priruba_[10]/1.9),
   (Rp02t_priruba_[11]/1.9),
   (Rp02t_priruba_[12]/1.9),
   (Rp02t_priruba_[13]/1.9),
   (Rp02t_priruba_[14]/1.9),
   (Rp02t_priruba_[15]/1.9),
   (Rp02t_priruba_[16]/1.9),
   (Rp02t_priruba_[17]/1.9),
   (Rp02t_priruba_[18]/1.9),
   (Rp02t_priruba_[19]/1.9),
   (Rp02t_priruba_[20]/1.9),]
pn=[(pn_[0]*ft[0]/140.),
    (pn_[1]*ft[1]/140.),
    (pn_[2]*ft[2]/140.),
    (pn_[3]*ft[3]/140.),
    (pn_[4]*ft[4]/140.),
    (pn_[5]*ft[5]/140.),
    (pn_[6]*ft[6]/140.),
    (pn_[7]*ft[7]/140.),
    (pn_[8]*ft[8]/140.),
    (pn_[9]*ft[9]/140.),
    (pn_[10]*ft[10]/140.),
    (pn_[11]*ft[11]/140.),
    (pn_[12]*ft[12]/140.),
    (pn_[13]*ft[13]/140.),
    (pn_[14]*ft[14]/140.),
    (pn_[15]*ft[15]/140.),
    (pn_[16]*ft[16]/140.),
    (pn_[17]*ft[17]/140.),
    (pn_[18]*ft[18]/140.),
    (pn_[19]*ft[19]/140.),
    (pn_[20]*ft[20]/140.),]
dbmin=[db[0]-2,
       db[1]-2,
       db[2]-2,
       db[3]-2,
       db[4]-2,
       db[5]-2,
       db[6]-2,
       db[7]-2,
       db[8]-2,
       db[9]-2,
       db[10]-2,
       db[11]-2,
       db[12]-2,
       db[13]-2,
       db[14]-2,
       db[15]-2,
       db[16]-2,
       db[17]-2,
       db[18]-2,
       db[19]-2,
       db[20]-2,] #d2              !!!!!!!
g1=[(d3[0]-B[0])/2.,
    (d3[1]-B[1])/2.,
    (d3[2]-B[2])/2.,
    (d3[3]-B[3])/2.,
    (d3[4]-B[4])/2.,
    (d3[5]-B[5])/2.,
    (d3[6]-B[6])/2.,
    (d3[7]-B[7])/2.,
    (d3[8]-B[8])/2.,
    (d3[9]-B[9])/2.,
    (d3[10]-B[10])/2.,
    (d3[11]-B[11])/2.,
    (d3[12]-B[12])/2.,
    (d3[13]-B[13])/2.,
    (d3[14]-B[14])/2.,
    (d3[15]-B[15])/2.,
    (d3[16]-B[16])/2.,
    (d3[17]-B[17])/2.,
    (d3[18]-B[18])/2.,
    (d3[19]-B[19])/2.,
    (d3[20]-B[20])/2.,]
deltab=[math.sqrt(2*((C[0]/2)**2)-(C[0]**2)/2*math.cos(2*math.pi/n[0])),
        math.sqrt(2*((C[1]/2)**2)-(C[1]**2)/2*math.cos(2*math.pi/n[1])),
        math.sqrt(2*((C[2]/2)**2)-(C[2]**2)/2*math.cos(2*math.pi/n[2])),
        math.sqrt(2*((C[3]/2)**2)-(C[3]**2)/2*math.cos(2*math.pi/n[3])),
        math.sqrt(2*((C[4]/2)**2)-(C[4]**2)/2*math.cos(2*math.pi/n[4])),
        math.sqrt(2*((C[5]/2)**2)-(C[5]**2)/2*math.cos(2*math.pi/n[5])),
        math.sqrt(2*((C[6]/2)**2)-(C[6]**2)/2*math.cos(2*math.pi/n[6])),
        math.sqrt(2*((C[7]/2)**2)-(C[7]**2)/2*math.cos(2*math.pi/n[7])),
        math.sqrt(2*((C[8]/2)**2)-(C[8]**2)/2*math.cos(2*math.pi/n[8])),
        math.sqrt(2*((C[9]/2)**2)-(C[9]**2)/2*math.cos(2*math.pi/n[9])),
        math.sqrt(2*((C[10]/2)**2)-(C[10]**2)/2*math.cos(2*math.pi/n[10])),
        math.sqrt(2*((C[11]/2)**2)-(C[11]**2)/2*math.cos(2*math.pi/n[11])),
        math.sqrt(2*((C[12]/2)**2)-(C[12]**2)/2*math.cos(2*math.pi/n[12])),
        math.sqrt(2*((C[13]/2)**2)-(C[13]**2)/2*math.cos(2*math.pi/n[13])),
        math.sqrt(2*((C[14]/2)**2)-(C[14]**2)/2*math.cos(2*math.pi/n[14])),
        math.sqrt(2*((C[15]/2)**2)-(C[15]**2)/2*math.cos(2*math.pi/n[15])),
        math.sqrt(2*((C[16]/2)**2)-(C[16]**2)/2*math.cos(2*math.pi/n[16])),
        math.sqrt(2*((C[17]/2)**2)-(C[17]**2)/2*math.cos(2*math.pi/n[17])),
        math.sqrt(2*((C[18]/2)**2)-(C[18]**2)/2*math.cos(2*math.pi/n[18])),
        math.sqrt(2*((C[19]/2)**2)-(C[19]**2)/2*math.cos(2*math.pi/n[19])),
        math.sqrt(2*((C[20]/2)**2)-(C[20]**2)/2*math.cos(2*math.pi/n[20])),]   
e=[b[0]-f[0],
   b[1]-f[1],
   b[2]-f[2],
   b[3]-f[3],
   b[4]-f[4],
   b[5]-f[5],
   b[6]-f[6],
   b[7]-f[7],
   b[8]-f[8],
   b[9]-f[9],
   b[10]-f[10],
   b[11]-f[11],
   b[12]-f[12],
   b[13]-f[13],
   b[14]-f[14],
   b[15]-f[15],
   b[16]-f[16],
   b[17]-f[17],
   b[18]-f[18],
   b[19]-f[19],
   b[20]-f[20],]
w=[(Dvtp[0]-Dstp[0])*2.,
   (Dvtp[1]-Dstp[1])*2.,
   (Dvtp[2]-Dstp[2])*2.,
   (Dvtp[3]-Dstp[3])*2.,
   (Dvtp[4]-Dstp[4])*2.,
   (Dvtp[5]-Dstp[5])*2.,
   (Dvtp[6]-Dstp[6])*2.,
   (Dvtp[7]-Dstp[7])*2.,
   (Dvtp[8]-Dstp[8])*2.,
   (Dvtp[9]-Dstp[9])*2.,
   (Dvtp[10]-Dstp[10])*2.,
   (Dvtp[11]-Dstp[11])*2.,
   (Dvtp[12]-Dstp[12])*2.,
   (Dvtp[13]-Dstp[13])*2.,
   (Dvtp[14]-Dstp[14])*2.,
   (Dvtp[15]-Dstp[15])*2.,
   (Dvtp[16]-Dstp[16])*2.,
   (Dvtp[17]-Dstp[17])*2.,
   (Dvtp[18]-Dstp[18])*2.,
   (Dvtp[19]-Dstp[19])*2.,
   (Dvtp[20]-Dstp[20])*2.,]       #           !!!!!!!!!
tloustka_priruby=[b[0]-f[0],
                  b[1]-f[1],
                  b[2]-f[2],
                  b[3]-f[3],
                  b[4]-f[4],
                  b[5]-f[5],
                  b[6]-f[6],
                  b[7]-f[7],
                  b[8]-f[8],
                  b[9]-f[9],
                  b[10]-f[10],
                  b[11]-f[11],
                  b[12]-f[12],
                  b[13]-f[13],
                  b[14]-f[14],
                  b[15]-f[15],
                  b[16]-f[16],
                  b[17]-f[17],
                  b[18]-f[18],
                  b[19]-f[19],
                  b[20]-f[20],]
tloustka_plaste=[(P[0]*B[0])/(2*167-P[0]),
                 (P[1]*B[1])/(2*167-P[1]),
                 (P[2]*B[2])/(2*167-P[2]),
                 (P[3]*B[3])/(2*167-P[3]),
                 (P[4]*B[4])/(2*167-P[4]),
                 (P[5]*B[5])/(2*167-P[5]),
                 (P[6]*B[6])/(2*167-P[6]),
                 (P[7]*B[7])/(2*167-P[7]),
                 (P[8]*B[8])/(2*167-P[8]),
                 (P[9]*B[9])/(2*167-P[9]),
                 (P[10]*B[10])/(2*167-P[10]),
                 (P[11]*B[11])/(2*167-P[11]),
                 (P[12]*B[12])/(2*167-P[12]),
                 (P[13]*B[13])/(2*167-P[13]),
                 (P[14]*B[14])/(2*167-P[14]),
                 (P[15]*B[15])/(2*167-P[15]),
                 (P[16]*B[16])/(2*167-P[16]),
                 (P[17]*B[17])/(2*167-P[17]),
                 (P[18]*B[18])/(2*167-P[18]),
                 (P[19]*B[19])/(2*167-P[19]),
                 (P[20]*B[20])/(2*167-P[20]),]

celkem_opakovani = len(d3)
for i in xrange(0,len(d3)):
    _vypocet = vypocet_2v0.vypocet() # tvorba instance vypoctu
    vysledky = _vypocet.vypocet_en13445(Temp[i], Temp_mont[i], material_sroubu[i], tloustka_sroubu[i], material_tesneni[i], tlakova_zkouska[i],
                            pn[i], g0[i], P[i], B[i], Dstp[i], Dvtp[i], dbmin[i], C[i], g1[i], deltab[i], db[i], e[i], A[i], w[i], h[i], v[i], material_priruby[i], tloustka_priruby[i],
                            material_plaste[i], tloustka_plaste[i])

    ## deklarace hodnot (z výsledků) do proměnných
    Rp02t_sroubu = vysledky[0][0]
    Rm_sroubu = vysledky[0][1]
    A_sroubu = vysledky[0][2]
    oznaceni_sroubu = vysledky[0][3][0]
    materialovy_ekvivalent_sroubu = vysledky[0][3][1]
    norma_sroubu = vysledky[0][3][2]
    Rp02t_priruba = vysledky[0][4]
    Rm_priruba = vysledky[0][5]
    A_priruba = vysledky[0][6]
    oznaceni_priruby = vysledky[0][7][0]
    materialovy_ekvivalent_priruby = vysledky[0][7][1]
    norma_priruby = vysledky[0][7][2]
    typ_tesneni = vysledky[0][8]
    m = vysledky[0][9]
    y = vysledky[0][10]
    w_min = vysledky[0][11]
    beta_2 = vysledky[0][12]
    Rp02t_plaste = vysledky[0][13]
    Rm_plaste = vysledky[0][14]
    A_plaste = vysledky[0][15]
    oznaceni_plaste = vysledky[0][16][0]
    materialovy_ekvivalent_plaste = vysledky[0][16][1]
    norma_plaste = vysledky[0][16][2]
    f_priruba = vysledky[0][17]
    f_sroubu = vysledky[0][18]
    f_sroubu_mont = vysledky[0][19]
    f_plaste = vysledky[0][20]
    priruba_pevnost = vysledky[1][0][0]
    typ_tesneni = vysledky[1][0][3]
    b0 = vysledky[2][0]
    b = vysledky[2][1]
    G = vysledky[2][2]
    H = vysledky[2][3]
    HG = vysledky[2][4]
    WA = vysledky[2][5]
    Wop = vysledky[2][6]
    ABmin = vysledky[2][7]
    AB = vysledky[2][8]
    HD = vysledky[2][9]
    HT = vysledky[2][10]
    hD = vysledky[2][11]
    hG = vysledky[2][12]
    hT = vysledky[2][13]
    W = vysledky[2][14]
    MA = vysledky[2][15]
    Mop = vysledky[2][16]
    CF = vysledky[2][17]
    K = vysledky[2][18]
    l0 = vysledky[2][19]
    betaT = vysledky[2][20]
    betaU = vysledky[2][21]
    betaY = vysledky[2][22]
    M_montaz = vysledky[2][23]
    M_provoz = vysledky[2][24]

    betaF = vysledky[2][25]
    betaV = vysledky[2][26]
    fi = vysledky[2][27]
    Lambda = vysledky[2][28]

    sigmaH_montaz = vysledky[2][29]
    sigmaH_provoz = vysledky[2][30]
    sigmar_montaz = vysledky[2][31]
    sigmar_provoz = vysledky[2][32]
    sigmaTHETA_montaz = vysledky[2][33]
    sigmaTHETA_provoz = vysledky[2][34]
  
    podminka_priruba = vysledky[1][0][1]
    podminka_tloustka_sroubu = vysledky[3][0][0]
    podminka_tloustka_priruby = vysledky[3][1][0]
    podminka_tloustka_plaste = vysledky[3][2][0]
    podminka_vstupni_hodnoty = vysledky[3][3]
    podminka_plochy_sroubu = vysledky[3][5]
    podminka_priruba_montaz = vysledky[3][7]
    podminka_priruba_provoz = vysledky[3][9]

    k_sigmaH_montaz = vysledky[4][0]
    k_sigmar_montaz = vysledky[4][1]
    k_sigmaTHETA_montaz = vysledky[4][2]
    k_sigmaH_montaz_sigmar_montaz = vysledky[4][3]
    k_sigmaH_montaz_sigmaTHETA_montaz = vysledky[4][4]
    k_sigmaH_provoz = vysledky[4][5]
    k_sigmar_provoz = vysledky[4][6]
    k_sigmaTHETA_provoz = vysledky[4][7]
    k_sigmaH_provoz_sigmar_provoz = vysledky[4][8]
    k_sigmaH_provoz_sigmaTHETA_provoz = vysledky[4][9]

    vysledky = _vypocet.vypocet_en13445(Temp[i], Temp_mont[i], material_sroubu[i], tloustka_sroubu[i], material_tesneni[i], tlakova_zkouska[i],
                            pn[i], g0[i], P[i], B[i], Dstp[i], Dvtp[i], dbmin[i], C[i], g1[i], deltab[i], db[i], e[i], A[i], w[i], h[i], v[i], material_priruby[i], tloustka_priruby[i],
                            material_plaste[i], tloustka_plaste[i])
    
    ## zápis hodnot do souboru
    hodnoty = (Temp[i],Temp_mont[i],material_sroubu[i],tloustka_sroubu[i],material_tesneni[i],tlakova_zkouska[i],pn[i],g0[i],P[i],B[i],Dstp[i],Dvtp[i],
               dbmin[i],C[i],g1[i],deltab[i],db[i],e[i],A[i],w[i],h[i],v[i],material_priruby[i],tloustka_priruby[i],material_plaste[i],tloustka_plaste[i],
               Rp02t_sroubu,Rm_sroubu,A_sroubu,oznaceni_sroubu,materialovy_ekvivalent_sroubu,norma_sroubu,
               Rp02t_priruba,Rm_priruba,A_priruba,oznaceni_priruby,materialovy_ekvivalent_priruby,norma_priruby,
               typ_tesneni,m,y,w_min,beta_2,Rp02t_plaste,Rm_plaste,A_plaste,oznaceni_plaste,materialovy_ekvivalent_plaste,
               norma_plaste,f_priruba,f_sroubu,f_sroubu_mont,f_plaste,priruba_pevnost,typ_tesneni,b0,b,G,H,HG,WA,Wop,
               ABmin,AB,HD,HT,hD,hG,hT,W,MA,Mop,CF,K,l0,betaT,betaU,betaY,M_montaz,M_provoz,betaF,betaV,fi,Lambda,sigmaH_montaz,sigmaH_provoz,sigmar_montaz,sigmar_provoz,sigmaTHETA_montaz,
               sigmaTHETA_provoz,podminka_priruba,podminka_tloustka_sroubu,podminka_tloustka_priruby,
               podminka_tloustka_plaste,podminka_vstupni_hodnoty,podminka_plochy_sroubu,podminka_priruba_montaz,
               podminka_priruba_provoz,k_sigmaH_montaz,k_sigmar_montaz,k_sigmaTHETA_montaz,k_sigmaH_montaz_sigmar_montaz,k_sigmaH_montaz_sigmaTHETA_montaz,
               k_sigmaH_provoz,k_sigmar_provoz,k_sigmaTHETA_provoz,k_sigmaH_provoz_sigmar_provoz,k_sigmaH_provoz_sigmaTHETA_provoz)
##    if podminka_priruba==True and podminka_tloustka_sroubu==True and podminka_tloustka_priruby==True and podminka_tloustka_plaste==True and podminka_vstupni_hodnoty==True and podminka_plochy_sroubu==True and podminka_priruba_montaz==True and podminka_priruba_provoz==True:
##        if Dvtp>Dstp and A>C and C>G and G>B and g1>g0 and g1<=(h+g0):
    for nazvy_hodnot in hodnoty:
        zapis.write('%s;' % str(nazvy_hodnot))
    zapis.write('\n')
    print ('aktualni stav vypoctu   %s;' % str(round((i*100./celkem_opakovani),2)))

zapis.close()
