x.append(xi)
        M.append(float(Mi))
        xi += step
    return [x, M]


supportCoefs = EC3lsc.SupportCoefficients(k1=1.0, k2=1.0)
nDiv = 20
step = 2 / nDiv
psi = list()
c1 = list()
psii = -1.0
C1i = 0.0
for i in range(1, nDiv + 2):
    mD = caseASampleMoments(5.0, 10.0, psii)
    mgf = EC3lsc.MomentGradientFactorC1(mD[0], mD[1])
    C1i = mgf.getC1(supportCoefs)
    psi.append(psii)
    c1.append(C1i)
    psii += step

C1Teor = [
    2.4494897427831783, 2.5202394341199024, 2.551789158017712,
    2.539514968727602, 2.485250608738542, 2.3965787580611124,
    2.284160962880643, 2.158748288883464, 2.0291986247835694,
    1.9017865941611045, 1.7803963942770489, 1.6670801802983037,
    1.5626453420774271, 1.4671286132146033, 1.3801311186847085,
    1.301036207838119, 1.229142533193964, 1.1637407889826492,
    1.1041549711386875, 1.0497621901901266, 1.0
]
ratio1 = 0
from materials.ec3 import EC3_materials

S355JR= EC3_materials.S355JR
gammaM0= 1.05
S355JR.gammaM= gammaM0 
IPE400= EC3_materials.IPEShape(S355JR,"IPE_400")


# Geometry
k1= 1.0; k2= 1.0
#Check results page 32
L= 6.0 # Bar length (m)
x= [0.0,0.25*L,0.5*L,0.75*L,1.0*L]
M= [-93.7,0,114.3,0,111.4]
Mi=intp.interpEquidistPoints(xi=x,yi=M,nDiv=4)
mgf= EC3lsc.MomentGradientFactorC1(Mi)
Mcr1= IPE400.getMcr(L,Mi)
Mcr1Teor= 164.7e3

ratio1= abs(Mcr1-Mcr1Teor)/Mcr1Teor
#NOTE: Here there is a big difference between the results
# from Lopez-Serna method
# 317 kN.m and those from the paper 164.7 kN.m
# In theory results from Lopez-Serna method are safe enough.

#Check results page 34
L= 3 # Bar length (m)
x= [0.0,0.25*L,0.5*L,0.75*L,1.0*L]
M= [-93.7e3,-93.7e3/2.0,0.0,114.3e3/2.0,114.3e3]
Mi=intp.interpEquidistPoints(xi=x,yi=M,nDiv=4)
mgf= EC3lsc.MomentGradientFactorC1(Mi)
import xc_base
import geom
import xc
import scipy.interpolate
from materials.ec3 import EC3_limit_state_checking as EC3lsc

__author__ = "Luis C. Pérez Tato (LCPT)"
__copyright__ = "Copyright 2014, LCPT"
__license__ = "GPL"
__version__ = "3.0"
__email__ = "*****@*****.**"

supportCoefs = EC3lsc.SupportCoefficients(k1=1.0, k2=1.0)
x = [0.0, 0.25, 0.5, 0.75, 1.0]
M = [50, 122.5, 105, -2.5, -200]
mgf1 = EC3lsc.MomentGradientFactorC1(x, M)
C11 = mgf1.getC1(supportCoefs)
C11Teor = math.sqrt(35 * 200**2 /
                    (200**2 + 9 * 122.5**2 + 16 * 105**2 + 9 * 2.5**2))
x = [0.0, 0.25, 0.4, 0.5, 0.75, 1.0]
M = [150, 260, 283.5, 280, 210, 50]
mgf2 = EC3lsc.MomentGradientFactorC1(x, M)
C12 = mgf2.getC1(supportCoefs)
C12Teor = math.sqrt(35 * 283.5**2 /
                    (283.5**2 + 9 * 260**2 + 16 * 280**2 + 9 * 210**2))

ratio1 = abs(C11 - C11Teor) / C11Teor
ratio2 = abs(C12 - C12Teor) / C12Teor

# print 'C1= ', C11
# print 'C1Teor= ', C11Teor