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,0,0,0,0,0,0]
a = [0,0.153832600,1.341953000,-2.998583000,-0.048312280,0.375796500,-1.589575000,-0.053588470,0.886594630,-0.710237040,-1.471722000,
1.321850350,-0.786659250,2.29129e-9,0.157672400,-0.436386400,-0.044081590,-0.003433888,0.032059050,0.024873550,0.073322790,
-0.001600573,0.642470600,-0.416260100,-0.066899570,0.279179500,-0.696605100,-0.002860589,-0.008098836,3.150547000,0.007224479,
-0.705752900,0.534979200,-0.079314910,-1.418465000,-5.99905e-17,0.105840200,0.034317290,-0.007022847,0.024955870,0.042968180,
0.746545300,-0.291961300,7.294616000,-9.936757000,-0.005399808,-0.243256700,0.049870160,0.003733797,1.874951000,0.002168144,
-0.658716400,0.000205518,0.009776195,-0.020487080,0.015573220,0.006862415,-0.001226752,0.002850908]
u = [0,0.0,0.5,1.0,3.5,-0.5,4.5,0.5,7.5,9.5,6.0,12.0,12.5,-6.0,2.0,3.0,2.0,2.0,11.0,-0.5,0.5,0.0,4.0,6.0,21.0,23.0,22.0,-1.0,-0.5,7.0,-1.0,
6.0,4.0,1.0,9.0,-13.0,21.0,8.0,-0.5,0.0,2.0,7.0,9.0,22.0,23.0,1.0,9.0,3.0,8.0,23.0,1.5,5.0,-0.5,4.0,7.0,3.0,0.0,1.0,0.0]
# 特征参数值
M = [0,16.0430,28.0135,44.0100,30.0700,44.0970,18.0153,34.0820,2.0159,28.0100,31.9988,58.1230,58.1230,72.1500,72.1500,86.1770,100.2040,114.2310,128.2580,142.2850,4.0026,39.9480]
E = [0,151.318300,99.737780,241.960600,244.166700,298.118300,514.015600,296.355000,26.957940,105.534800,122.766700,324.068900,337.638900,365.599900,370.682300,402.636293,427.722630,450.325022,470.840891,489.558373,2.610111,119.629900]
G = [0,0.0,0.027815,0.189065,0.079300,0.141239,0.332500,0.088500,0.034369,0.038953,0.021000,0.256692,0.281835,0.332267,0.366911,0.289731,0.337542,0.383381,0.427354,0.469659,0.0,0.0]
Q = [0,0.0,0.0,0.690000,0.0,0.0,1.067750,0.633276,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
K = [0,0.4619255,0.4479153,0.4557489,0.5279209,0.5837490,0.3825868,0.4618263,0.3514916,0.4533894,0.4186954,0.6406937,0.6341423,0.6738577,0.6798307,0.7175118,0.7525189,0.7849550,0.8152731,0.8437826,0.3589888,0.4216551]
# 交互作用参数值
Ex = [[0],
[0,1,0.971640,0.960644,1,0.994635,0.708218,0.931484,1.170520,0.990126,1,1.019530,0.989844,1.002350,0.999268,1.107274,0.880880,0.880973,0.881067,0.881161,1,1],
[0,0.971640,1,1.022740,0.970120,0.945939,0.746954,0.902271,1.086320,1.005710,1.021000,0.946914,0.973384,0.959340,0.945520,1,1,1,1,1,1,1],
[0,0.960644,1.022740,1,0.925053,0.960237,0.849408,0.955052,1.281790,1.500000,1,0.906849,0.897362,0.726255,0.859764,0.855134,0.831229,0.808310,0.786323,0.765171,1,1],
[0,1,0.970120,0.925053,1,1.022560,0.693168,0.946871,1.164460,1,1,1,1.013060,1,1.005320,1,1,1,1,1,1,1],
[0,0.994635,0.945939,0.960237,1.022560,1,1,1,1.034787,1,1,1,1.004900,1,1,1,1,1,1,1,1,1],
[0,0.708218,0.746954,0.849408,0.693168,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,0.931484,0.902271,0.955052,0.946871,1,1,1,1,1,1,1,1,1,1,1.008692,1.010126,1.011501,1.012821,1.014089,1,1],
[0,1.170520,1.086320,1.281790,1.164460,1.034787,1,1,1,1.100000,1,1.300000,1.300000,1,1,1,1,1,1,1,1,1],
[0,0.990126,1.005710,1.500000,1,1,1,1,1.100000,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1.021000,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1.019530,0.946914,0.906849,1,1,1,1,1.300000,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,0.989844,0.973384,0.897362,1.013060,1.004900,1,1,1.300000,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1.002350,0.959340,0.726255,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,0.999268,0.945520,0.859764,1.005320,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1.107274,1,0.855134,1,1,1,1.008692,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,0.880880,1,0.831229,1,1,1,1.010126,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,0.880973,1,0.808310,1,1,1,1.011501,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,0.881067,1,0.786323,1,1,1,1.012821,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,0.881161,1,0.765171,1,1,1,1.014089,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]
Gx =[[0],
[0,1,1,0.807653,1,1,1,1,1.957310,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,0.982746,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,0.807653,0.982746,1,0.370296,1,1.673090,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,0.370296,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1.673090,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1.957310,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]
Ux = [[0],
[0,1,0.886106,0.963827,1,0.990877,1,0.736833,1.156390,1,1,1,0.992291,1,1.003670,1.302576,1.191904,1.205769,1.219634,1.233498,1,1],
[0,0.886106,1,0.835058,0.816431,0.915502,1,0.993476,0.408838,1,1,1,0.993556,1,1,1,1,1,1,1,1,1],
[0,0.963827,0.835058,1,0.969870,1,1,1.045290,1,0.900000,1,1,1,1,1,1.066638,1.077634,1.088178,1.098291,1.108021,1,1],
[0,1,0.816431,0.969870,1,1.065173,1,0.971926,1.616660,1,1,1.25,1.25,1.25,1.25,1,1,1,1,1,1,1],
[0,0.990877,0.915502,1,1.065173,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,0.736833,0.993476,1.045290,0.971926,1,1,1,1,1,1,1,1,1,1,1.028973,1.033754,1.038338,1.042735,1.046966,1,1],
[0,1.156390,0.408838,1,1.616660,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,0.900000,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1.25,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,0.992291,0.993556,1,1.250000,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1,1,1,1.25,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1.003670,1,1,1.25,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1.302576,1,1.066638,1,1,1,1.028973,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1.191904,1,1.077634,1,1,1,1.033754,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[0,1