Private Function calculo_resultados() Application.Sheets("Datos

Anuncio
Private Function calculo_resultados()
Application.Sheets("Datos generales").Activate
Dim n_barras As Integer
Dim n_nudos As Integer
Dim n_cargas As Integer
Dim i As Integer
Dim j As Integer
Dim z As Integer
n_cargas = Range("AK1").Value
Dim array_cargas() As Carga
For i = 3 To n_cargas + 2
If i = 3 Then
ReDim array_cargas(0)
Else
ReDim Preserve array_cargas(UBound(array_cargas) + 1)
End If
array_cargas(UBound(array_cargas)).n = Sheets("Datos Generales").Range("AI" & i).Value
array_cargas(UBound(array_cargas)).en = Sheets("Datos Generales").Range("AJ" & i).Value
array_cargas(UBound(array_cargas)).id = Sheets("Datos Generales").Range("AK" & i).Value
array_cargas(UBound(array_cargas)).tipo = Sheets("Datos Generales").Range("AL" & i).Value
array_cargas(UBound(array_cargas)).sentido = Sheets("Datos Generales").Range("AM" & i).Value
array_cargas(UBound(array_cargas)).valor = Sheets("Datos Generales").Range("AN" & i).Value
array_cargas(UBound(array_cargas)).distancia = Sheets("Datos Generales").Range("AO" & i).Value
array_cargas(UBound(array_cargas)).hipotesis = Sheets("Datos Generales").Range("AP" & i).Value
Next i
n_barras = Range("H1").Value
n_nudos = Range("C1").Value
'Coloco los resultados de desplazamientos en cada una de las hojas de K_elementos
Dim hoja_tex As String
Dim rango_result1 As String
Dim rango_result2 As String
Dim n_incog As Integer
Application.Sheets("Matriz rigidez reducida").Activate
n_incog = Application.CountA(Range("B1:B65536")) - 2
rango_result1 = rango(n_incog + 5, n_incog + 4) & ":" & rango(2 * n_incog + 4, n_incog + 4)
rango_result2 = rango(n_incog + 5, n_incog + 4) & ":" & rango(2 * n_incog + 4, n_incog + 5)
Dim formula As String
For i = 1 To n_barras
hoja_tex = "Barra" & CStr(i)
Application.Sheets(hoja_tex).Activate
Range("P15").Value = "Desplz"
For j = 17 To 28
formula = "INDICE('Matriz rigidez reducida'!" & rango_result2 & ";COINCIDIR(B" & CStr(j) & ";'Matriz rigidez reducida'!"
& rango_result1 & ";0);2)"
formula = "=SI(ESERROR(" & formula & ");0;" & formula & ")"
Range("P" & CStr(j)).FormulaLocal = formula
Next j
Range("Z3:Z14").Select
Selection.FormulaArray = "=MMULT(C17:N28,P17:P28)"
Range("V2").Value = "Esfuerzos"
Range("V3:V14").Select
Selection.Value = Range("Q17:Q28").Value
'
'
Range("Y3:Y14").Select
Selection.FormulaArray = "=MMULT(C46:N57;Z3:Z14)"
For z = 46 To 57
formula = ""
For j = 3 To 14
formula = formula & "(" & rango(z, j) & "*" & rango(j, 26) & ")+"
Next j
formula = Left(formula, Len(formula) - 1)
formula = "=" & formula
Range(rango(z - 43, 25)).FormulaLocal = formula
Next z
For j = 3 To 14
Range("X" & CStr(j)).FormulaLocal = "=S" & CStr(14 + j)
If Range("X" & CStr(j)).Value = 0 Then
Range("W" & CStr(j)).FormulaLocal = "=Y" & CStr(j)
Else
Range("W" & CStr(j)).FormulaLocal = "=Y" & CStr(j) & "-X" & CStr(j)
End If
ActiveSheet.Calculate
Next j
Next i
'Genera una hoja nueva
Dim hoja As Worksheet
Set hoja = ActiveWorkbook.Sheets.Add
'La movemos al final
ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
Application.ScreenUpdating = True
'Le damos nombre
hoja.Name = "Resultados"
ActiveSheet.Cells(1, 1).Value = "Nudo"
ActiveSheet.Cells(1, 2).Value = "X_ini"
ActiveSheet.Cells(1, 3).Value = "Y_ini"
ActiveSheet.Cells(1, 4).Value = "Z_ini"
ActiveSheet.Cells(1, 5).Value = "Desp.X_"
ActiveSheet.Cells(1, 6).Value = "Desp.Y_"
ActiveSheet.Cells(1, 7).Value = "Desp.Z_"
ActiveSheet.Cells(1, 8).Value = "Giro en X_"
ActiveSheet.Cells(1, 9).Value = "Giro en Y_"
ActiveSheet.Cells(1, 10).Value = "Giro en Z_"
ActiveSheet.Cells(1, 12).Value = "Escala"
ActiveSheet.Cells(2, 12).Value = 1
Range("A2:D" & n_nudos + 1).Select
Selection.FormulaArray = "='Datos generales'!A3:D" & n_nudos + 2
Dim n_veces As Integer
Dim texto As String
n_veces = Application.CountA(Range("'Matriz rigidez reducida'!B1:B65536"))
For i = 1 To n_nudos
texto = Chr(34) & "Despl.X_" & CStr(i) & Chr(34)
formula = "INDICE('Matriz rigidez reducida'!" & rango(n_veces + 2, n_veces + 2) & ":" & rango(2 * n_veces, n_veces + 3) &
";COINCIDIR(" & texto & ";'Matriz rigidez reducida'!" & rango(n_veces + 2, n_veces + 2) & ":" & rango(2 * n_veces, n_veces + 2) &
";0);2))"
formula = "=SI(ESERROR(" & formula & ";0;(" & formula & ")"
Range(rango(i + 1, 5)).FormulaLocal = formula
texto = Chr(34) & "Despl.Y_" & CStr(i) & Chr(34)
formula = "INDICE('Matriz rigidez reducida'!" & rango(n_veces + 2, n_veces + 2) & ":" & rango(2 * n_veces, n_veces + 3) &
";COINCIDIR(" & texto & ";'Matriz rigidez reducida'!" & rango(n_veces + 2, n_veces + 2) & ":" & rango(2 * n_veces, n_veces + 2) &
";0);2))"
formula = "=SI(ESERROR(" & formula & ";0;(" & formula & ")"
Range(rango(i + 1, 6)).FormulaLocal = formula
texto = Chr(34) & "Despl.Z_" & CStr(i) & Chr(34)
formula = "INDICE('Matriz rigidez reducida'!" & rango(n_veces + 2, n_veces + 2) & ":" & rango(2 * n_veces, n_veces + 3) &
";COINCIDIR(" & texto & ";'Matriz rigidez reducida'!" & rango(n_veces + 2, n_veces + 2) & ":" & rango(2 * n_veces, n_veces + 2) &
";0);2))"
formula = "=SI(ESERROR(" & formula & ";0;(" & formula & ")"
Range(rango(i + 1, 7)).FormulaLocal = formula
texto = Chr(34) & "Giro en X_" & CStr(i) & Chr(34)
formula = "INDICE('Matriz rigidez reducida'!" & rango(n_veces + 2, n_veces + 2) & ":" & rango(2 * n_veces, n_veces + 3) &
";COINCIDIR(" & texto & ";'Matriz rigidez reducida'!" & rango(n_veces + 2, n_veces + 2) & ":" & rango(2 * n_veces, n_veces + 2) &
";0);2))"
formula = "=SI(ESERROR(" & formula & ";0;(" & formula & ")"
Range(rango(i + 1, 8)).FormulaLocal = formula
texto = Chr(34) & "Giro en Y_" & CStr(i) & Chr(34)
formula = "INDICE('Matriz rigidez reducida'!" & rango(n_veces + 2, n_veces + 2) & ":" & rango(2 * n_veces, n_veces + 3) &
";COINCIDIR(" & texto & ";'Matriz rigidez reducida'!" & rango(n_veces + 2, n_veces + 2) & ":" & rango(2 * n_veces, n_veces + 2) &
";0);2))"
formula = "=SI(ESERROR(" & formula & ";0;(" & formula & ")"
Range(rango(i + 1, 9)).FormulaLocal = formula
texto = Chr(34) & "Giro en Z_" & CStr(i) & Chr(34)
formula = "INDICE('Matriz rigidez reducida'!" & rango(n_veces + 2, n_veces + 2) & ":" & rango(2 * n_veces, n_veces + 3) &
";COINCIDIR(" & texto & ";'Matriz rigidez reducida'!" & rango(n_veces + 2, n_veces + 2) & ":" & rango(2 * n_veces, n_veces + 2) &
";0);2))"
formula = "=SI(ESERROR(" & formula & ";0;(" & formula & ")"
Range(rango(i + 1, 10)).FormulaLocal = formula
'
'
Range(rango(i + 1, 6)).FormulaLocal = "=" & rango(i + 1, 2) & "+" & "$H$2*" & rango(i + 1, 4)
Range(rango(i + 1, 7)).FormulaLocal = "=" & rango(i + 1, 3) & "+" & "$H$2*" & rango(i + 1, 5)
Next i
Dim
Dim
Dim
Dim
Dim
Dim
Dim
Dim
fila As Integer
funcion1 As String
funcion2 As String
funcion3 As String
funcion4 As String
colocada As Boolean
dist As String
Mizd As String
Dim Vizd As String
Dim Qy As String
Dim k As Integer
fila = 0
Dim rango_nudos As String
rango_nudos = "A1:J" & CStr(n_nudos + 1)
fila = n_nudos + fila + 3
For i = 1 To n_barras
ActiveSheet.Cells(fila, 1).Value = "Barra"
ActiveSheet.Cells(fila, 2).Value = CStr(i)
ActiveSheet.Cells(fila, 4).Value = "Nudo1"
ActiveSheet.Cells(fila, 5).Value = "='Barra" & CStr(i) & "'!F3"
ActiveSheet.Cells(fila, 7).Value = "Nudo2"
ActiveSheet.Cells(fila, 8).Value = "='Barra" & CStr(i) & "'!F4"
ActiveSheet.Cells(fila, 10).Value = "Longitud"
ActiveSheet.Cells(fila, 11).FormulaLocal = "=RAIZ((" & rango(fila + 2, 8) & "-" & rango(fila + 2, 2) & ")^2+(" & rango(fila +
3, 8) & "-" & rango(fila + 3, 2) & ")^2)"
ActiveSheet.Cells(fila + 1, 10).Value = "Giro"
ActiveSheet.Cells(fila + 1, 11).FormulaLocal = "=SI(" & rango(fila + 2, 8) & "=" & rango(fila + 2, 2) & ";0,5*PI();SI(" &
rango(fila + 3, 8) & "=" & rango(fila + 3, 2) & ";0;ATAN((" & rango(fila + 3, 8) & "-" & rango(fila + 3, 2) & ")/(" & rango(fila + 2,
8) & "-" & rango(fila + 2, 2) & "))))"
fila = fila + 1
ActiveSheet.Cells(fila, 1).Value = "%L"
ActiveSheet.Cells(fila, 2).FormulaLocal = "=" & rango(fila - 1, 11) & "* 0"
ActiveSheet.Cells(fila, 3).FormulaLocal = "=" & rango(fila - 1, 11) & "* 0,1667"
ActiveSheet.Cells(fila, 4).FormulaLocal = "=" & rango(fila - 1, 11) & "* 0,3333"
ActiveSheet.Cells(fila, 5).FormulaLocal = "=" & rango(fila - 1, 11) & "* 0,5"
ActiveSheet.Cells(fila, 6).FormulaLocal = "=" & rango(fila - 1, 11) & "* 0,6667"
ActiveSheet.Cells(fila, 7).FormulaLocal = "=" & rango(fila - 1, 11) & "* 0,8333"
ActiveSheet.Cells(fila, 8).FormulaLocal = "=" & rango(fila - 1, 11) & "* 1"
fila = fila + 1
ActiveSheet.Cells(fila, 1).Value = "Coor.X_ini"
ActiveSheet.Cells(fila, 2).FormulaLocal = "=BUSCARV(" & rango(fila - 2, 5) & ";" & rango_nudos & ";2)"
ActiveSheet.Cells(fila, 8).FormulaLocal = "=BUSCARV(" & rango(fila - 2, 8) & ";" & rango_nudos & ";2)"
ActiveSheet.Cells(fila, 3).FormulaLocal = "=" & rango(fila, 2) & "+((" & rango(fila, 8) & "-" & rango(fila,
rango(fila - 1, 3) & "/" & rango(fila - 2, 11) & "))"
ActiveSheet.Cells(fila, 4).FormulaLocal = "=" & rango(fila, 2) & "+((" & rango(fila, 8) & "-" & rango(fila,
rango(fila - 1, 4) & "/" & rango(fila - 2, 11) & "))"
ActiveSheet.Cells(fila, 5).FormulaLocal = "=" & rango(fila, 2) & "+((" & rango(fila, 8) & "-" & rango(fila,
rango(fila - 1, 5) & "/" & rango(fila - 2, 11) & "))"
ActiveSheet.Cells(fila, 6).FormulaLocal = "=" & rango(fila, 2) & "+((" & rango(fila, 8) & "-" & rango(fila,
rango(fila - 1, 6) & "/" & rango(fila - 2, 11) & "))"
ActiveSheet.Cells(fila, 7).FormulaLocal = "=" & rango(fila, 2) & "+((" & rango(fila, 8) & "-" & rango(fila,
rango(fila - 1, 7) & "/" & rango(fila - 2, 11) & "))"
2) & ")*(" &
2) & ")*(" &
2) & ")*(" &
2) & ")*(" &
2) & ")*(" &
fila = fila + 1
ActiveSheet.Cells(fila, 1).Value = "Coor.Y_ini"
ActiveSheet.Cells(fila, 2).FormulaLocal = "=BUSCARV(" & rango(fila - 3, 5) & ";" & rango_nudos & ";3)"
ActiveSheet.Cells(fila, 8).FormulaLocal = "=BUSCARV(" & rango(fila - 3, 8) & ";" & rango_nudos & ";3)"
ActiveSheet.Cells(fila, 3).FormulaLocal = "=" & rango(fila, 2) & "+((" & rango(fila, 8) & "-" & rango(fila, 2) & ")*(" &
rango(fila - 2, 3) & "/" & rango(fila - 3, 11) & "))"
ActiveSheet.Cells(fila, 4).FormulaLocal = "="
rango(fila - 2, 4) & "/" & rango(fila - 3, 11) & "))"
ActiveSheet.Cells(fila, 5).FormulaLocal = "="
rango(fila - 2, 5) & "/" & rango(fila - 3, 11) & "))"
ActiveSheet.Cells(fila, 6).FormulaLocal = "="
rango(fila - 2, 6) & "/" & rango(fila - 3, 11) & "))"
ActiveSheet.Cells(fila, 7).FormulaLocal = "="
rango(fila - 2, 7) & "/" & rango(fila - 3, 11) & "))"
fila = fila + 1
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
fila = fila + 1
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
& rango(fila, 2) & "+((" & rango(fila, 8) & "-" & rango(fila, 2) & ")*(" &
& rango(fila, 2) & "+((" & rango(fila, 8) & "-" & rango(fila, 2) & ")*(" &
& rango(fila, 2) & "+((" & rango(fila, 8) & "-" & rango(fila, 2) & ")*(" &
& rango(fila, 2) & "+((" & rango(fila, 8) & "-" & rango(fila, 2) & ")*(" &
1).Value = "Giro en Z_"
2).FormulaLocal = "=(BUSCARV(" & rango(fila - 4, 5) & ";" & rango_nudos & ";10))*L2"
8).FormulaLocal = "=(BUSCARV(" & rango(fila - 4, 8) & ";" & rango_nudos & ";10))*L2"
1).Value = "Despl.X_Loc"
2).FormulaLocal = "=(BUSCARV(" & rango(fila - 5, 5) & ";" & rango_nudos & ";5))*L2"
8).FormulaLocal = "=(BUSCARV(" & rango(fila - 5, 8) & ";" & rango_nudos & ";5))*L2"
funcion1 = "(((" & rango(fila - 5, 11) & "*((1-(" & rango(fila - 4, 3) & "/" & rango(fila - 5, 11) & "))^2)*(" & rango(fila 4, 3) & "/" & rango(fila - 5, 11) & ")))*(1)*" & rango(fila - 1, 2) & ")"
funcion2 = "(((-" & rango(fila - 5, 11) & "*((1-(" & rango(fila - 4, 3) & "/" & rango(fila - 5, 11) & ")))*((" & rango(fila 4, 3) & "/" & rango(fila - 5, 11) & ")^2)))*(1)*" & rango(fila - 1, 8) & ")"
funcion3 = "((((3*((1-(" & rango(fila - 4, 3) & "/" & rango(fila - 5, 11) & "))^2))-(2*((1-(" & rango(fila - 4, 3) & "/" &
rango(fila - 5, 11) & "))^3))))*" & rango(fila, 2) & ")"
funcion4 = "((((3*(((" & rango(fila - 4, 3) & "/" & rango(fila - 5, 11) & "))^2))-(2*(((" & rango(fila - 4, 3) & "/" &
rango(fila - 5, 11) & "))^3))))*" & rango(fila, 8) & ")"
ActiveSheet.Cells(fila, 3).FormulaLocal = "=(" & funcion1 & "+" & funcion2 & "+" & funcion3 & "+" & funcion4 & ")"
funcion1 = "(((" & rango(fila - 5, 11) & "*((1-(" & rango(fila - 4, 4) & "/" & rango(fila - 5, 11) & "))^2)*(" & rango(fila 4, 4) & "/" & rango(fila - 5, 11) & ")))*(1)*" & rango(fila - 1, 2) & ")"
funcion2 = "(((-" & rango(fila - 5, 11) & "*((1-(" & rango(fila - 4, 4) & "/" & rango(fila - 5, 11) & ")))*((" & rango(fila 4, 4) & "/" & rango(fila - 5, 11) & ")^2)))*(1)*" & rango(fila - 1, 8) & ")"
funcion3 = "((((3*((1-(" & rango(fila - 4, 4) & "/" & rango(fila - 5, 11) & "))^2))-(2*((1-(" & rango(fila - 4, 4) & "/" &
rango(fila - 5, 11) & "))^3))))*" & rango(fila, 2) & ")"
funcion4 = "((((3*(((" & rango(fila - 4, 4) & "/" & rango(fila - 5, 11) & "))^2))-(2*(((" & rango(fila - 4, 4) & "/" &
rango(fila - 5, 11) & "))^3))))*" & rango(fila, 8) & ")"
ActiveSheet.Cells(fila, 4).FormulaLocal = "=(" & funcion1 & "+" & funcion2 & "+" & funcion3 & "+" & funcion4 & ")"
funcion1 = "(((" & rango(fila - 5, 11) & "*((1-(" & rango(fila - 4, 5) & "/" & rango(fila - 5, 11) & "))^2)*(" & rango(fila 4, 5) & "/" & rango(fila - 5, 11) & ")))*(1)*" & rango(fila - 1, 2) & ")"
funcion2 = "(((-" & rango(fila - 5, 11) & "*((1-(" & rango(fila - 4, 5) & "/" & rango(fila - 5, 11) & ")))*((" & rango(fila 4, 5) & "/" & rango(fila - 5, 11) & ")^2)))*(1)*" & rango(fila - 1, 8) & ")"
funcion3 = "((((3*((1-(" & rango(fila - 4, 5) & "/" & rango(fila - 5, 11) & "))^2))-(2*((1-(" & rango(fila - 4, 5) & "/" &
rango(fila - 5, 11) & "))^3))))*" & rango(fila, 2) & ")"
funcion4 = "((((3*(((" & rango(fila - 4, 5) & "/" & rango(fila - 5, 11) & "))^2))-(2*(((" & rango(fila - 4, 5) & "/" &
rango(fila - 5, 11) & "))^3))))*" & rango(fila, 8) & ")"
ActiveSheet.Cells(fila, 5).FormulaLocal = "=(" & funcion1 & "+" & funcion2 & "+" & funcion3 & "+" & funcion4 & ")"
funcion1 = "(((" & rango(fila - 5, 11) & "*((1-(" & rango(fila - 4, 6) & "/" & rango(fila - 5, 11) & "))^2)*(" & rango(fila 4, 6) & "/" & rango(fila - 5, 11) & ")))*(1)*" & rango(fila - 1, 2) & ")"
funcion2 = "(((-" & rango(fila - 5, 11) & "*((1-(" & rango(fila - 4, 6) & "/" & rango(fila - 5, 11) & ")))*((" & rango(fila 4, 6) & "/" & rango(fila - 5, 11) & ")^2)))*(1)*" & rango(fila - 1, 8) & ")"
funcion3 = "((((3*((1-(" & rango(fila - 4, 6) & "/" & rango(fila - 5, 11) & "))^2))-(2*((1-(" & rango(fila - 4, 6) & "/" &
rango(fila - 5, 11) & "))^3))))*" & rango(fila, 2) & ")"
funcion4 = "((((3*(((" & rango(fila - 4, 6) & "/" & rango(fila - 5, 11) & "))^2))-(2*(((" & rango(fila - 4, 6) & "/" &
rango(fila - 5, 11) & "))^3))))*" & rango(fila, 8) & ")"
ActiveSheet.Cells(fila, 6).FormulaLocal = "=(" & funcion1 & "+" & funcion2 & "+" & funcion3 & "+" & funcion4 & ")"
funcion1 = "(((" & rango(fila - 5, 11) & "*((1-(" & rango(fila - 4, 7) & "/" & rango(fila - 5, 11) & "))^2)*(" & rango(fila 4, 7) & "/" & rango(fila - 5, 11) & ")))*(1)*" & rango(fila - 1, 2) & ")"
funcion2 = "(((-" & rango(fila - 5, 11) & "*((1-(" & rango(fila - 4, 7) & "/" & rango(fila - 5, 11) & ")))*((" & rango(fila 4, 7) & "/" & rango(fila - 5, 11) & ")^2)))*(1)*" & rango(fila - 1, 8) & ")"
funcion3 = "((((3*((1-(" & rango(fila - 4, 7) & "/" & rango(fila - 5, 11) & "))^2))-(2*((1-(" & rango(fila - 4, 7) & "/" &
rango(fila - 5, 11) & "))^3))))*" & rango(fila, 2) & ")"
funcion4 = "((((3*(((" & rango(fila - 4, 7) & "/" & rango(fila - 5, 11) & "))^2))-(2*(((" & rango(fila - 4, 7) & "/" &
rango(fila - 5, 11) & "))^3))))*" & rango(fila, 8) & ")"
ActiveSheet.Cells(fila, 7).FormulaLocal = "=(" & funcion1 & "+" & funcion2 & "+" & funcion3 & "+" & funcion4 & ")"
fila = fila + 1
ActiveSheet.Cells(fila, 1).Value = "Despl.Y_Loc"
ActiveSheet.Cells(fila, 2).FormulaLocal = "=(BUSCARV(" & rango(fila - 6, 5) & ";" & rango_nudos & ";6))*L2"
ActiveSheet.Cells(fila, 8).FormulaLocal = "=(BUSCARV(" & rango(fila - 6, 8) & ";" & rango_nudos & ";6))*L2"
funcion1 = "(((" & rango(fila - 6, 11) & "*((1-(" & rango(fila - 5, 3) & "/" & rango(fila - 6, 11) & "))^2)*(" & rango(fila 5, 3) & "/" & rango(fila - 6, 11) & ")))*(1)*" & rango(fila - 2, 2) & ")"
funcion2 = "(((-" & rango(fila - 6, 11) & "*((1-(" & rango(fila - 5, 3) & "/" & rango(fila - 6, 11) & ")))*((" & rango(fila 5, 3) & "/" & rango(fila - 6, 11) & ")^2)))*(1)*" & rango(fila - 2, 8) & ")"
funcion3 = "((((3*((1-(" & rango(fila - 5, 3) & "/" & rango(fila - 6, 11) & "))^2))-(2*((1-(" & rango(fila - 5, 3) & "/" &
rango(fila - 6, 11) & "))^3))))*" & rango(fila, 2) & ")"
funcion4 = "((((3*(((" & rango(fila - 5, 3) & "/" & rango(fila - 6, 11) & "))^2))-(2*(((" & rango(fila - 5, 3) & "/" &
rango(fila - 6, 11) & "))^3))))*" & rango(fila, 8) & ")"
ActiveSheet.Cells(fila, 3).FormulaLocal = "=(" & funcion1 & "+" & funcion2 & "+" & funcion3 & "+" & funcion4 & ")"
funcion1 = "(((" & rango(fila - 6, 11) & "*((1-(" & rango(fila - 5, 4) & "/" & rango(fila - 6, 11) & "))^2)*(" & rango(fila 5, 4) & "/" & rango(fila - 6, 11) & ")))*(1)*" & rango(fila - 2, 2) & ")"
funcion2 = "(((-" & rango(fila - 6, 11) & "*((1-(" & rango(fila - 5, 4) & "/" & rango(fila - 6, 11) & ")))*((" & rango(fila 5, 4) & "/" & rango(fila - 6, 11) & ")^2)))*(1)*" & rango(fila - 2, 8) & ")"
funcion3 = "((((3*((1-(" & rango(fila - 5, 4) & "/" & rango(fila - 6, 11) & "))^2))-(2*((1-(" & rango(fila - 5, 4) & "/" &
rango(fila - 6, 11) & "))^3))))*" & rango(fila, 2) & ")"
funcion4 = "((((3*(((" & rango(fila - 5, 4) & "/" & rango(fila - 6, 11) & "))^2))-(2*(((" & rango(fila - 5, 4) & "/" &
rango(fila - 6, 11) & "))^3))))*" & rango(fila, 8) & ")"
ActiveSheet.Cells(fila, 4).FormulaLocal = "=(" & funcion1 & "+" & funcion2 & "+" & funcion3 & "+" & funcion4 & ")"
funcion1 = "(((" & rango(fila - 6, 11) & "*((1-(" & rango(fila - 5, 5) & "/" & rango(fila - 6, 11) & "))^2)*(" & rango(fila 5, 5) & "/" & rango(fila - 6, 11) & ")))*(1)*" & rango(fila - 2, 2) & ")"
funcion2 = "(((-" & rango(fila - 6, 11) & "*((1-(" & rango(fila - 5, 5) & "/" & rango(fila - 6, 11) & ")))*((" & rango(fila 5, 5) & "/" & rango(fila - 6, 11) & ")^2)))*(1)*" & rango(fila - 2, 8) & ")"
funcion3 = "((((3*((1-(" & rango(fila - 5, 5) & "/" & rango(fila - 6, 11) & "))^2))-(2*((1-(" & rango(fila - 5, 5) & "/" &
rango(fila - 6, 11) & "))^3))))*" & rango(fila, 2) & ")"
funcion4 = "((((3*(((" & rango(fila - 5, 5) & "/" & rango(fila - 6, 11) & "))^2))-(2*(((" & rango(fila - 5, 5) & "/" &
rango(fila - 6, 11) & "))^3))))*" & rango(fila, 8) & ")"
ActiveSheet.Cells(fila, 5).FormulaLocal = "=(" & funcion1 & "+" & funcion2 & "+" & funcion3 & "+" & funcion4 & ")"
funcion1 = "(((" & rango(fila - 6, 11) & "*((1-(" & rango(fila - 5, 6) & "/" & rango(fila - 6, 11) & "))^2)*(" & rango(fila 5, 6) & "/" & rango(fila - 6, 11) & ")))*(1)*" & rango(fila - 2, 2) & ")"
funcion2 = "(((-" & rango(fila - 6, 11) & "*((1-(" & rango(fila - 5, 6) & "/" & rango(fila - 6, 11) & ")))*((" & rango(fila 5, 6) & "/" & rango(fila - 6, 11) & ")^2)))*(1)*" & rango(fila - 2, 8) & ")"
funcion3 = "((((3*((1-(" & rango(fila - 5, 6) & "/" & rango(fila - 6, 11) & "))^2))-(2*((1-(" & rango(fila - 5, 6) & "/" &
rango(fila - 6, 11) & "))^3))))*" & rango(fila, 2) & ")"
funcion4 = "((((3*(((" & rango(fila - 5, 6) & "/" & rango(fila - 6, 11) & "))^2))-(2*(((" & rango(fila - 5, 6) & "/" &
rango(fila - 6, 11) & "))^3))))*" & rango(fila, 8) & ")"
ActiveSheet.Cells(fila, 6).FormulaLocal = "=(" & funcion1 & "+" & funcion2 & "+" & funcion3 & "+" & funcion4 & ")"
funcion1 = "(((" & rango(fila - 6, 11) & "*((1-(" & rango(fila - 5, 7) & "/" & rango(fila - 6, 11) & "))^2)*(" & rango(fila 5, 7) & "/" & rango(fila - 6, 11) & ")))*(1)*" & rango(fila - 2, 2) & ")"
funcion2 = "(((-" & rango(fila - 6, 11) & "*((1-(" & rango(fila - 5, 7) & "/" & rango(fila - 6, 11) & ")))*((" & rango(fila 5, 7) & "/" & rango(fila - 6, 11) & ")^2)))*(1)*" & rango(fila - 2, 8) & ")"
funcion3 = "((((3*((1-(" & rango(fila - 5, 7) & "/" & rango(fila - 6, 11) & "))^2))-(2*((1-(" & rango(fila - 5, 7) & "/" &
rango(fila - 6, 11) & "))^3))))*" & rango(fila, 2) & ")"
funcion4 = "((((3*(((" & rango(fila - 5, 7) & "/" & rango(fila - 6, 11) & "))^2))-(2*(((" & rango(fila - 5, 7) & "/" &
rango(fila - 6, 11) & "))^3))))*" & rango(fila, 8) & ")"
ActiveSheet.Cells(fila, 7).FormulaLocal = "=(" & funcion1 & "+" & funcion2 & "+" & funcion3 & "+" & funcion4 & ")"
2) &
3) &
4) &
5) &
6) &
7) &
8) &
2) &
3) &
4) &
5) &
6) &
7) &
8) &
fila = fila + 1
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
"*SENO(" & rango(fila - 6,
ActiveSheet.Cells(fila,
"*SENO(" & rango(fila - 6,
ActiveSheet.Cells(fila,
"*SENO(" & rango(fila - 6,
ActiveSheet.Cells(fila,
"*SENO(" & rango(fila - 6,
ActiveSheet.Cells(fila,
"*SENO(" & rango(fila - 6,
ActiveSheet.Cells(fila,
"*SENO(" & rango(fila - 6,
ActiveSheet.Cells(fila,
"*SENO(" & rango(fila - 6,
1).Value = "Despl.X_Glob"
2).FormulaLocal = "=" & rango(fila
11) & ")"
3).FormulaLocal = "=" & rango(fila
11) & ")"
4).FormulaLocal = "=" & rango(fila
11) & ")"
5).FormulaLocal = "=" & rango(fila
11) & ")"
6).FormulaLocal = "=" & rango(fila
11) & ")"
7).FormulaLocal = "=" & rango(fila
11) & ")"
8).FormulaLocal = "=" & rango(fila
11) & ")"
fila = fila + 1
ActiveSheet.Cells(fila, 1).Value = "Despl.Y_Glob"
ActiveSheet.Cells(fila, 2).FormulaLocal = "=" & rango(fila
"*COS(" & rango(fila - 7, 11) & ")"
ActiveSheet.Cells(fila, 3).FormulaLocal = "=" & rango(fila
"*COS(" & rango(fila - 7, 11) & ")"
ActiveSheet.Cells(fila, 4).FormulaLocal = "=" & rango(fila
"*COS(" & rango(fila - 7, 11) & ")"
ActiveSheet.Cells(fila, 5).FormulaLocal = "=" & rango(fila
"*COS(" & rango(fila - 7, 11) & ")"
ActiveSheet.Cells(fila, 6).FormulaLocal = "=" & rango(fila
"*COS(" & rango(fila - 7, 11) & ")"
ActiveSheet.Cells(fila, 7).FormulaLocal = "=" & rango(fila
"*COS(" & rango(fila - 7, 11) & ")"
ActiveSheet.Cells(fila, 8).FormulaLocal = "=" & rango(fila
"*COS(" & rango(fila - 7, 11) & ")"
fila = fila + 1
- 2, 2) & "*COS(" & rango(fila - 6, 11) & ")-" & rango(fila - 1,
- 2, 3) & "*COS(" & rango(fila - 6, 11) & ")-" & rango(fila - 1,
- 2, 4) & "*COS(" & rango(fila - 6, 11) & ")-" & rango(fila - 1,
- 2, 5) & "*COS(" & rango(fila - 6, 11) & ")-" & rango(fila - 1,
- 2, 6) & "*COS(" & rango(fila - 6, 11) & ")-" & rango(fila - 1,
- 2, 7) & "*COS(" & rango(fila - 6, 11) & ")-" & rango(fila - 1,
- 2, 8) & "*COS(" & rango(fila - 6, 11) & ")-" & rango(fila - 1,
- 3, 2) & "*SENO(" & rango(fila - 7, 11) & ")+" & rango(fila - 2,
- 3, 3) & "*SENO(" & rango(fila - 7, 11) & ")+" & rango(fila - 2,
- 3, 4) & "*SENO(" & rango(fila - 7, 11) & ")+" & rango(fila - 2,
- 3, 5) & "*SENO(" & rango(fila - 7, 11) & ")+" & rango(fila - 2,
- 3, 6) & "*SENO(" & rango(fila - 7, 11) & ")+" & rango(fila - 2,
- 3, 7) & "*SENO(" & rango(fila - 7, 11) & ")+" & rango(fila - 2,
- 3, 8) & "*SENO(" & rango(fila - 7, 11) & ")+" & rango(fila - 2,
'
'
'
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
1).Value = "Coor.X_fin"
2).FormulaLocal = "=" &
3).FormulaLocal = "=" &
4).FormulaLocal = "=" &
5).FormulaLocal = "=" &
6).FormulaLocal = "=" &
7).FormulaLocal = "=" &
8).FormulaLocal = "=" &
rango(fila
rango(fila
rango(fila
rango(fila
rango(fila
rango(fila
rango(fila
-
2,
2,
2,
2,
2,
2,
2,
2)
3)
4)
5)
6)
7)
8)
&
&
&
&
&
&
&
"+"
"+"
"+"
"+"
"+"
"+"
"+"
&
&
&
&
&
&
&
rango(fila
rango(fila
rango(fila
rango(fila
rango(fila
rango(fila
rango(fila
-
7,
7,
7,
7,
7,
7,
7,
2)
3)
4)
5)
6)
7)
8)
fila = fila + 1
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
ActiveSheet.Cells(fila,
1).Value = "Coor.Y_fin"
2).FormulaLocal = "=" &
3).FormulaLocal = "=" &
4).FormulaLocal = "=" &
5).FormulaLocal = "=" &
6).FormulaLocal = "=" &
7).FormulaLocal = "=" &
8).FormulaLocal = "=" &
rango(fila
rango(fila
rango(fila
rango(fila
rango(fila
rango(fila
rango(fila
-
2,
2,
2,
2,
2,
2,
2,
2)
3)
4)
5)
6)
7)
8)
&
&
&
&
&
&
&
"+"
"+"
"+"
"+"
"+"
"+"
"+"
&
&
&
&
&
&
&
rango(fila
rango(fila
rango(fila
rango(fila
rango(fila
rango(fila
rango(fila
-
7,
7,
7,
7,
7,
7,
7,
2)
3)
4)
5)
6)
7)
8)
fila = fila + 1
ActiveSheet.Cells(fila, 1).Value = "Qx"
For j = 1 To n_cargas
If (array_cargas(j - 1).en = "Barra") Then
If (array_cargas(j - 1).id = Range(rango(fila - 11, 2)).Value) _
And (array_cargas(j - 1).sentido = "X") _
And (array_cargas(j - 1).tipo = "Distribuida") Then
For k = 2 To 8
ActiveSheet.Cells(fila, k).Value = array_cargas(j - 1).valor
Next k
Else
For k = 2 To 8
ActiveSheet.Cells(fila, k).Value = 0
Next k
End If
If (array_cargas(j - 1).id = Range(rango(fila - 11, 2)).Value) _
And (array_cargas(j - 1).sentido = "X") _
And (array_cargas(j - 1).tipo = "Puntual") Then
colocada = False
For k = 2 To 8
If (ActiveSheet.Cells(fila - 10, k).Value >= array_cargas(j - 1).distancia) _
And (colocada = False) Then
ActiveSheet.Cells(fila, k).Value = array_cargas(j - 1).valor
colocada = True
Else
ActiveSheet.Cells(fila, k).Value = 0
End If
Next k
End If
End If
Next j
fila = fila + 1
ActiveSheet.Cells(fila, 1).Value = "Qy"
'
'
'
For j = 1 To n_cargas
If (array_cargas(j - 1).en = "Barra") Then
If (array_cargas(j - 1).id = Range(rango(fila - 12, 2)).Value) _
And (array_cargas(j - 1).sentido = "Y") _
And (array_cargas(j - 1).tipo = "Distribuida") Then
For k = 2 To 8
ActiveSheet.Cells(fila, k).Value = array_cargas(j - 1).valor
Next k
Else
For k = 2 To 8
ActiveSheet.Cells(fila, k).Value = 0
Next k
End If
If (array_cargas(j - 1).id = Range(rango(fila - 12, 2)).Value) _
And (array_cargas(j - 1).sentido = "Y") _
And (array_cargas(j - 1).tipo = "Puntual") Then
colocada = False
For k = 2 To 8
If (ActiveSheet.Cells(fila - 11, k).Value >= array_cargas(j - 1).distancia) _
And (colocada = False) Then
ActiveSheet.Cells(fila, k).Value = array_cargas(j - 1).valor
colocada = True
Else
ActiveSheet.Cells(fila, k).Value = 0
End If
Next k
End If
End If
Next j
fila = fila + 1
ActiveSheet.Cells(fila, 1).Value = "Axil"
ActiveSheet.Cells(fila, 2).Value = "=(-1)*'Barra" & CStr(i) & "'!W3"
ActiveSheet.Cells(fila, 8).Value = "='Barra" & CStr(i) & "'!W9"
If (ActiveSheet.Cells(fila - 2, 2).Value = ActiveSheet.Cells(fila - 2, 3).Value) _
And (ActiveSheet.Cells(fila - 2, 2).Value = ActiveSheet.Cells(fila - 2, 4).Value) _
And (ActiveSheet.Cells(fila - 2, 2).Value = ActiveSheet.Cells(fila - 2, 5).Value) _
And (ActiveSheet.Cells(fila - 2, 2).Value = ActiveSheet.Cells(fila - 2, 6).Value) _
And (ActiveSheet.Cells(fila - 2, 2).Value = ActiveSheet.Cells(fila - 2, 7).Value) _
And (ActiveSheet.Cells(fila - 2, 2).Value = ActiveSheet.Cells(fila - 2, 8).Value) Then
'es una carga distribuida
For k = 3 To 7
ActiveSheet.Cells(fila, k).FormulaLocal = "=" & rango(fila, k - 1) & "+((" & rango(fila - 12, k) & "-" & rango(fila 12, k - 1) & ")*" & rango(fila - 2, k) & ")"
Next k
Else
For k = 3 To 7
If (ActiveSheet.Cells(fila - 2, k).Value = ActiveSheet.Cells(fila - 2, k - 1).Value) Then
ActiveSheet.Cells(fila, k).Value = ActiveSheet.Cells(fila, k - 1).Value
Else
ActiveSheet.Cells(fila, k).Value = ActiveSheet.Cells(fila, k - 1).Value + ActiveSheet.Cells(fila - 2, k).Value
End If
Next k
End If
fila = fila + 1
ActiveSheet.Cells(fila, 1).Value = "Vy"
ActiveSheet.Cells(fila, 2).Value = "='Barra" & CStr(i) & "'!W4"
ActiveSheet.Cells(fila, 8).Value = "=(-1)*'Barra" & CStr(i) & "'!W10"
If (ActiveSheet.Cells(fila - 2, 2).Value = ActiveSheet.Cells(fila - 2, 3).Value) _
And (ActiveSheet.Cells(fila - 2, 2).Value = ActiveSheet.Cells(fila - 2, 4).Value) _
And (ActiveSheet.Cells(fila - 2, 2).Value = ActiveSheet.Cells(fila - 2, 5).Value) _
And (ActiveSheet.Cells(fila - 2, 2).Value = ActiveSheet.Cells(fila - 2, 6).Value) _
And (ActiveSheet.Cells(fila - 2, 2).Value = ActiveSheet.Cells(fila - 2, 7).Value) _
And (ActiveSheet.Cells(fila - 2, 2).Value = ActiveSheet.Cells(fila - 2, 8).Value) Then
'es una carga distribuida
For k = 3 To 7
ActiveSheet.Cells(fila, k).FormulaLocal = "=" & rango(fila, k - 1) & "+((" & rango(fila - 13, k) & "-" & rango(fila 13, k - 1) & ")*" & rango(fila - 2, k) & ")"
Next k
Else
For k = 3 To 7
If (ActiveSheet.Cells(fila - 2, k).Value = ActiveSheet.Cells(fila - 2, k - 1).Value) Then
ActiveSheet.Cells(fila, k).Value = ActiveSheet.Cells(fila, k - 1).Value
Else
ActiveSheet.Cells(fila, k).Value = ActiveSheet.Cells(fila, k - 1).Value + ActiveSheet.Cells(fila - 2, k).Value
End If
Next k
End If
fila = fila + 1
ActiveSheet.Cells(fila, 1).Value = "Mz"
ActiveSheet.Cells(fila, 2).Value = "=(-1)*'Barra" & CStr(i) & "'!W8"
ActiveSheet.Cells(fila, 8).Value = "='Barra" & CStr(i) & "'!W14"
If (ActiveSheet.Cells(fila - 3, 2).Value = ActiveSheet.Cells(fila - 3, 3).Value) _
And (ActiveSheet.Cells(fila - 3, 2).Value = ActiveSheet.Cells(fila - 3, 4).Value) _
And (ActiveSheet.Cells(fila - 3, 2).Value = ActiveSheet.Cells(fila - 3, 5).Value) _
And (ActiveSheet.Cells(fila - 3, 2).Value = ActiveSheet.Cells(fila - 3, 6).Value) _
And (ActiveSheet.Cells(fila - 3, 2).Value = ActiveSheet.Cells(fila - 3, 7).Value) _
And (ActiveSheet.Cells(fila - 3, 2).Value = ActiveSheet.Cells(fila - 3, 8).Value) Then
'es una carga distribuida
For k = 3 To 7
dist = rango(fila - 14, k) & "-" & rango(fila - 14, 2)
Mizd = rango(fila, 2)
Vizd = rango(fila - 1, 2)
Qy = rango(fila - 3, k)
ActiveSheet.Cells(fila, k).FormulaLocal = "=(" & Mizd & "+ (" & Vizd & "*(" & dist & ")) + (0,5 *" & Qy & "* ((" &
dist & ") ^ 2)))"
Next k
Else
colocada = False
For k = 3 To 7
If (ActiveSheet.Cells(fila - 3, k).Value = ActiveSheet.Cells(fila - 3, k - 1).Value) _
And (colocada = False) Then
'Aun no esta aplicada la carga
dist = rango(fila - 14, k) & "-" & rango(fila - 14,
Mizd = rango(fila, 2)
Vizd = rango(fila - 1, 2)
ActiveSheet.Cells(fila, k).FormulaLocal = "=-1 * ("
Else
'Ya esta aplicada la carga
colocada = True
dist = rango(fila - 14, 8) & "-" & rango(fila - 14,
Mizd = rango(fila, 8)
Vizd = rango(fila - 1, 8)
ActiveSheet.Cells(fila, k).FormulaLocal = "=-1 * ("
End If
Next k
2)
& Mizd & "+ (" & Vizd & "*" & dist & "))"
k)
& Mizd & "- (" & Vizd & "*" & dist & "))"
End If
fila = fila + 1
ActiveSheet.Cells(fila, 1).Value = "X_Girado"
For k = 2 To 8
ActiveSheet.Cells(fila, k).FormulaLocal = "=(" & rango(fila - 15, k) & ")*COS(" & rango(fila - 15, 11) & ")-SENO(" &
rango(fila - 15, 11) & ")*($L$2*" & rango(fila - 10, k) & ")+" & rango(fila - 14, 2) 'rango(fila - 10, k) rango define la ley Desplz
Y Locales
Next k
fila = fila + 1
ActiveSheet.Cells(fila, 1).Value = "Y_Girado"
For k = 2 To 8
ActiveSheet.Cells(fila, k).FormulaLocal = "=" & rango(fila - 16, k) & "*seno(" & rango(fila - 16, 11) & ")+COS(" &
rango(fila - 16, 11) & ")*($L$2*" & rango(fila - 11, k) & ")+" & rango(fila - 14, 2) 'rango(fila - 11, k) rango define la ley Desplz
Y Locales
Next k
fila = fila + 3
Next i
'
'
'
'
Dim chrt As ChartObject
Set chrt = ActiveSheet.ChartObjects.Add _
(Left:=100, Width:=750, Top:=130, Height:=440)
chrt.Chart.ChartType = xlXYScatterLines
chrt.Chart.Axes(xlValue).Select
Selection.Delete
chrt.Chart.Axes(xlCategory).Select
Selection.Delete
fila = n_nudos + 5
For i = 1 To n_barras
chrt.Chart.SeriesCollection.NewSeries
chrt.Chart.SeriesCollection(2 * i - 1).XValues = "=Resultados!" & rango_dolar(fila, 2) & ",Resultados!" & rango_dolar(fila,
8)
chrt.Chart.SeriesCollection(2 * i - 1).Values = "=Resultados!" & rango_dolar(fila + 1, 2) & ",Resultados!" & rango_dolar(fila
+ 1, 8)
chrt.Chart.SeriesCollection(2 * i - 1).Name = "Barra" & CStr(i)
chrt.Chart.SeriesCollection(2 * i - 1).MarkerStyle = 8
chrt.Chart.SeriesCollection(2 * i - 1).MarkerSize = 15
chrt.Chart.SeriesCollection(2 * i - 1).MarkerBackgroundColorIndex = 3
chrt.Chart.SeriesCollection(2 * i - 1).MarkerForegroundColorIndex = 3
chrt.Chart.SeriesCollection(2 * i - 1).Format.Line.Weight = 5
chrt.Chart.SeriesCollection(2 * i - 1).Border.Color = RGB(0, 0, 0)
chrt.Chart.SeriesCollection.NewSeries
chrt.Chart.SeriesCollection(2 * i).XValues = "=Resultados!" & rango_dolar(fila + 14, 2) & ":" & rango_dolar(fila + 14, 8)
chrt.Chart.SeriesCollection(2 * i).Values = "=Resultados!" & rango_dolar(fila + 15, 2) & ":" & rango_dolar(fila + 15, 8)
chrt.Chart.SeriesCollection(2 * i).Name = "Def.Barra" & CStr(i)
chrt.Chart.SeriesCollection(2 * i).MarkerStyle = xlMarkerStyleNone
chrt.Chart.SeriesCollection(2 * i).Format.Line.Weight = 2
chrt.Chart.SeriesCollection(2 * i).Border.Color = RGB(255, 0, 0)
fila = fila + 20
Next i
chrt.Chart.Axes(xlCategory).HasMinorGridlines = False
chrt.Chart.Axes(xlValue).HasMajorGridlines = False
chrt.Chart.Axes(xlValue).HasMinorGridlines = False
chrt.Chart.HasLegend = False
chrt.Chart.HasTitle = True
chrt.Chart.ChartTitle.Text = "Deformada"
End Function
Private Function calculo_barras()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim n_elementos As Integer
Dim n_nodos As Integer
Dim n_secciones As Integer
Dim n_materiales As Integer
Dim n_cargas As Integer
Dim n_apoyos As Integer
n_secciones = Range("T1").Value
n_materiales = Range("N1").Value
n_elementos = Range("H1").Value
n_nodos = Range("C1").Value
n_cargas = Range("AK1").Value
Dim array_cargas() As Carga
For i = 3 To n_cargas + 2
If i = 3 Then
ReDim array_cargas(0)
Else
ReDim Preserve array_cargas(UBound(array_cargas) + 1)
End If
array_cargas(UBound(array_cargas)).n = Sheets("Datos Generales").Range("AI" & i).Value
array_cargas(UBound(array_cargas)).en = Sheets("Datos Generales").Range("AJ" & i).Value
array_cargas(UBound(array_cargas)).id = Sheets("Datos Generales").Range("AK" & i).Value
array_cargas(UBound(array_cargas)).tipo = Sheets("Datos Generales").Range("AL" & i).Value
array_cargas(UBound(array_cargas)).sentido = Sheets("Datos Generales").Range("AM" & i).Value
array_cargas(UBound(array_cargas)).valor = Sheets("Datos Generales").Range("AN" & i).Value
array_cargas(UBound(array_cargas)).distancia = Sheets("Datos Generales").Range("AO" & i).Value
array_cargas(UBound(array_cargas)).hipotesis = Sheets("Datos Generales").Range("AP" & i).Value
Next i
Dim hoja As Worksheet
For i = 0 To n_elementos - 1
'Genera una hoja nueva
Set hoja = ActiveWorkbook.Sheets.Add
'La movemos al final
ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
Application.ScreenUpdating = True
'Le damos nombre
hoja.Name = "Barra" & i & "_R"
'Rellenamos las casillas
Range("B2:M14").FormulaArray = "=Barra" & i & "!C45:N57"
Range("O2:O14").FormulaArray = "=Barra" & i & "!A16:A28"
Range("P2").Value = "Despl.locales"
For j = 3 To 14
Range("P" & j).FormulaLocal = "=SI(ESERROR(INDICE('Matriz rigidez reducida'!A3:R14;COINCIDIR(O" & j & ";'Matriz rigidez
reducida'!A3:A14;0);18));0;INDICE('Matriz rigidez reducida'!A3:R14;COINCIDIR(O" & j & ";'Matriz rigidez reducida'!A3:A14;0);18))"
Next j
Range("Q2").Value = "Esf.locales"
Range("Q3:Q14").FormulaArray = "=MMULT(B3:M14,P3:P14)"
Range("R3").Value = "Axil"
Range("R4").Value = "Vy"
Range("R5").Value = "Vz"
Range("R6").Value = "Torsor"
Range("R7").Value = "My"
Range("R8").Value = "Mz"
Range("R9").Value = "Axil"
Range("R10").Value = "Vy"
Range("R11").Value = "Vz"
Range("R12").Value = "Torsor"
Range("R13").Value = "My"
Range("R14").Value = "Mz"
Range("B16").Value = "L="
Range("C16").FormulaLocal = "=Barra" & i & "!C3"
Range("B18").Value = "x"
Range("C18").Value = "x/L"
Range("D17").Value = "Flexión"
Range("D17:G17").Cells.Merge
Range("D17:G17").Cells.HorizontalAlignment = xlCenter
Range("D18").Value = "TITA1u"
Range("E18").Value = "TITA2u"
Range("F18").Value = "TITA1g"
Range("G18").Value = "TITA2g"
Range("H17").Value = "Axil"
Range("H17:I17").Cells.Merge
Range("H17:I17").Cells.HorizontalAlignment = xlCenter
Range("H18").Value = "TITA1u"
Range("I18").Value = "TITA2u"
Range("J18").Value = "ux"
Range("K18").Value = "ux"
Range("L18").Value = "ux"
For j = 19 To 44
If j = 19 Then
Range("B" & j).Value = 0
Else
Range("B" & j).FormulaLocal = "=0,04*C16+B" & (j - 1)
End If
Range("C" & j).FormulaLocal = "=B" & j & "/C16"
Range("D" & j).FormulaLocal = "=1-3*((C" & j & ")^2)+2*((C" & j & ")^3)"
Range("E" & j).FormulaLocal = "=3*((C" & j & ")^2)-2*((C" & j & ")^3)"
Range("F" & j).FormulaLocal = "=C16*((C" & j & ")-2*((C" & j & ")^2)+((C" & j & ")^3))"
Range("G" & j).FormulaLocal = "=C16*(-((C" & j & ")^2)+((C" & j & ")^3))"
Range("H" & j).FormulaLocal = "=1-C" & j
Range("I" & j).FormulaLocal = "=C" & j
Range("J" & j).FormulaLocal = "=(H" & j & "*P3+I" & j & "*P9)"
Range("K" & j).FormulaLocal = "=(H" & j & "*P3+I" & j & "*P9)"
Range("L" & j).FormulaLocal = "=(H" & j & "*P3+I" & j & "*P9)"
Next j
Next i
End Function
Private Function ensambla_matriz_indirecta()
Application.Sheets("Datos generales").Activate
Dim n_elementos As Integer
Dim n_nodos As Integer
Dim hoja As Worksheet
n_elementos = Range("H1").Value
n_nodos = Range("C1").Value
'Genera una hoja nueva
Set hoja = ActiveWorkbook.Sheets.Add
'La movemos al final
ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
Application.ScreenUpdating = True
'Le damos nombre
hoja.Name = "Matriz global de rigidez"
Range("B1").Value = "Columna"
Range("A2").Value = "Fila"
Range("B2").Value = "Nodos"
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim nodo As String
j = 3
For i = 1 To n_nodos
nodo = Sheets("Datos generales").Range("A" & (i + 2)).Value
ActiveSheet.Cells(j, 2).FormulaLocal = "Despl.X_" & nodo
ActiveSheet.Cells(j + 1, 2).FormulaLocal = "Despl.Y_" & nodo
ActiveSheet.Cells(j + 2, 2).FormulaLocal = "Despl.Z_" & nodo
ActiveSheet.Cells(j + 3, 2).FormulaLocal = "Giro en X_" & nodo
ActiveSheet.Cells(j + 4, 2).FormulaLocal = "Giro en Y_" & nodo
ActiveSheet.Cells(j + 5, 2).FormulaLocal = "Giro en Z_" & nodo
For k = j To (j + 5)
'ActiveSheet.Cells(k, 2).FormulaLocal = "='Datos generales'!A" & CStr(i + 2)
ActiveSheet.Cells(2, k).FormulaLocal = "='Datos generales'!A" & CStr(i + 2)
ActiveSheet.Cells(1, k).FormulaR1C1 = "=(6*R[1]C)+" & (k - 2) & "-(6*R[1]C)"
'ActiveSheet.Cells(k, 1).FormulaR1C1 = "=(6*RC[1])+" & (k - 2) & "-(6*RC[1])"
ActiveSheet.Cells(k, 1).FormulaR1C1 = "=" & Range(rango(1, k))
Next k
j = k
Next i
Dim codigo_funct As String
codigo_funct = Codigo
Dim
Dim
Dim
Dim
Dim
Dim
formula As String
formula1 As String
cadena_barra As String
sigue As Boolean
filas(1 To 12) As Integer
columnas(1 To 12) As Integer
For k = 1 To 1 'n_elementos
cadena_barra = "Barra" & CStr(k)
Range("A1").Value = CStr(k)
'Rellena arrays de filas y columnas ocupadas por este elemento
For i = 1 To 12
filas(i) = Sheets(cadena_barra).Range("A" & (16 + i)).Value
Next
For i = 1 To 12
columnas(i) = filas(i)
Next
'Quita el coloreado a todas las celdas
Range("C3:" & rango(((6 * n_nodos) + 2), (6 * n_nodos) + 2)).Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
For i = 3 To ((6 * n_nodos) + 2) 'filas
For j = 3 To ((6 * n_nodos) + 2) 'columnas
formula1 = ""
formula1 = Range(rango(i, j)).FormulaLocal
formula = "INDICE(" & cadena_barra & "!C17:N28;COINCIDIR(" & rango(1, j) & ";" & cadena_barra &
"!C15:N15;0);COINCIDIR(" & rango(i, 1) & ";" & cadena_barra & "!A17:A28;0)))"
If k = 1 Then
formula1 = "=SI(ESERROR(" & formula & ";0;(" & formula & ")"
Else
formula1 = formula1 & "+ SI(ESERROR(" & formula & ";0;(" & formula & ")"
End If
Range(rango(i, j)).FormulaLocal = formula1
If Pertence((i - 2), (j - 2), filas, columnas) Then 'colorea la celda
Range(rango(i, j)).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = xlThemeColorAccent6
.TintAndShade = 0.599993896298105
.PatternTintAndShade = 0
End With
End If
Next j
Next i
Range("A1").Select
Application.CutCopyMode = False
sigue = MsgBox("El elemento 'Barra" & (k) & "' ha sido ensamblado", vbOKOnly)
Next k
End Function
Private Function dibuja_estructura()
Application.Sheets("Datos generales").Activate
Dim n_nodos As Integer
n_nodos = Range("C1").Value
Dim n_elementos As Integer
n_elementos = Range("H1").Value
Dim hoja As Worksheet
'Generamos la hoja
Set hoja = Worksheets.Add
'La movemos al final
hoja.Activate
hoja.Move After:=Sheets("Datos generales")
Application.ScreenUpdating = True
hoja.Name = "Estructura"
Range(rango(1, 1)).Value = "Nodos"
Range(rango(2, 1) & ":" & rango((2 + n_nodos), 3)).FormulaArray = "='Datos generales'!" & rango(2, 2) & ":" & rango((2 +
n_nodos), 4)
Range(rango(1, 5)).Value = "Angulos"
Range(rango(2, 5)).Value = "Control"
Range(rango(2, 6)).Value = "Grados"
Range(rango(2, 7)).Value = "Radianes"
Range(rango(1, 9)).Value = "Perspectiva"
Range(rango(2, 9)).Value = "Control"
Range(rango(2, 10)).Value = "Distancia"
Range(rango(4, 6)).Value = 0
Range(rango(4, 7)).FormulaLocal = "=RADIANES(F4)"
Call Añade_control_numero(rango(4, 5), 360)
Range(rango(6, 6)).Value = 45
Range(rango(6, 7)).FormulaLocal = "=RADIANES(F6)"
Call Añade_control_numero(rango(6, 5), 360)
Range(rango(8, 6)).Value = 45
Range(rango(8, 7)).FormulaLocal = "=RADIANES(F8)"
Call Añade_control_numero(rango(8, 5), 360)
Range(rango(4, 10)).Value = 20
Call Añade_control_numero(rango(4, 9), 20)
Range(rango(1, 12)).Value = "Translacion centroide"
Range(rango(2,
Range(rango(2,
Range(rango(2,
Range(rango(1,
Range(rango(2,
Range(rango(2,
Range(rango(2,
Range(rango(1,
Range(rango(2,
Range(rango(2,
Range(rango(2,
Range(rango(1,
Range(rango(2,
Range(rango(2,
Range(rango(2,
Range(rango(1,
Range(rango(2,
Range(rango(2,
12)).Value
13)).Value
14)).Value
16)).Value
16)).Value
17)).Value
18)).Value
20)).Value
20)).Value
21)).Value
22)).Value
24)).Value
24)).Value
25)).Value
26)).Value
28)).Value
28)).Value
29)).Value
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
"Xt"
"Yt"
"Zt"
"1ªRotacion"
"X1"
"Y1"
"Z1"
"2ªRotacion"
"X1"
"Y1"
"Z1"
"3ªRotacion"
"X1"
"Y1"
"Z1"
"Perspectiva"
"Xp"
"Yp"
Dim i As Integer
For i = 3 To n_nodos + 2
Range(rango(i, 12)).FormulaLocal = "=(A" & i & "-PROMEDIO(A3:A" & (n_nodos + 2) & "))/1000"
Range(rango(i, 13)).FormulaLocal = "=(B" & i & "-PROMEDIO(B3:B" & (n_nodos + 2) & "))/1000"
Range(rango(i, 14)).FormulaLocal = "=(C" & i & "-PROMEDIO(C3:C" & (n_nodos + 2) & "))/1000"
Range(rango(i, 16)).FormulaLocal = "=L" & i & "*COS(G4)+M" & i & "*SENO(G4)"
Range(rango(i, 17)).FormulaLocal = "=-L" & i & "*SENO(G4)+M" & i & "*COS(G4)"
Range(rango(i, 18)).FormulaLocal = "=N" & i
Range(rango(i, 20)).FormulaLocal = "=-R" & i & "*SENO(G6)+P" & i & "*COS(G6)"
Range(rango(i, 21)).FormulaLocal = "=Q" & i
Range(rango(i, 22)).FormulaLocal = "=R" & i & "*COS(G6)+P" & i & "*SENO(G6)"
Range(rango(i, 24)).FormulaLocal = "=T" & i
Range(rango(i, 25)).FormulaLocal = "=U" & i & "*COS(G8)+V" & i & "*SENO(G8)"
Range(rango(i, 26)).FormulaLocal = "=-U" & i & "*SENO(G8)+V" & i & "*COS(G8)"
Range(rango(i, 28)).FormulaLocal = "=X" & i & "*J4/(Z" & i & "+J4)"
Range(rango(i, 29)).FormulaLocal = "=Y" & i & "*J4/(Z" & i & "+J4)"
Next i
Dim nodos_inicial() As Integer
Dim nodos_final() As Integer
For i = 1 To n_elementos
If i = 1 Then
ReDim nodos_inicial(0)
ReDim nodos_final(0)
Else
ReDim Preserve nodos_inicial(UBound(nodos_inicial) + 1)
ReDim Preserve nodos_final(UBound(nodos_final) + 1)
End If
nodos_inicial(UBound(nodos_inicial)) = ActiveWorkbook.Sheets("Datos generales").Range(rango((i + 2), 7)).Value
nodos_final(UBound(nodos_inicial)) = ActiveWorkbook.Sheets("Datos generales").Range(rango((i + 2), 8)).Value
Next i
Dim chrt As ChartObject
Set chrt = ActiveSheet.ChartObjects.Add _
(Left:=100, Width:=750, Top:=130, Height:=440)
chrt.Chart.ChartType = xlXYScatterLines
chrt.Chart.Axes(xlValue).Select
Selection.Delete
chrt.Chart.Axes(xlCategory).Select
Selection.Delete
For i = 1 To n_elementos
chrt.Chart.SeriesCollection.NewSeries
chrt.Chart.SeriesCollection(i).XValues = "=Estructura!$AB$" & CStr(nodos_inicial(i - 1) + 2) & ",Estructura!$AB$" &
CStr(nodos_final(i - 1) + 2)
chrt.Chart.SeriesCollection(i).Values = "=Estructura!$AC$" & CStr(nodos_inicial(i - 1) + 2) & ",Estructura!$AC$" &
CStr(nodos_final(i - 1) + 2)
chrt.Chart.SeriesCollection(i).Name = "Barra" & CStr(i)
chrt.Chart.Axes(xlCategory).HasMinorGridlines = False
chrt.Chart.Axes(xlValue).HasMajorGridlines = False
chrt.Chart.Axes(xlValue).HasMinorGridlines = False
chrt.Chart.HasLegend = False
chrt.Chart.SeriesCollection(i).MarkerStyle = 8
chrt.Chart.SeriesCollection(i).MarkerSize = 15
chrt.Chart.SeriesCollection(i).MarkerBackgroundColorIndex = 3
chrt.Chart.SeriesCollection(i).MarkerForegroundColorIndex = 3
chrt.Chart.SeriesCollection(i).Format.Line.Weight = 5
chrt.Chart.SeriesCollection(i).Border.Color = RGB(0, 0, 0)
Next i
End Function
Private Function ensambla_k_reducida()
Application.Sheets("Datos generales").Activate
Dim n_apoyos As Integer
n_apoyos = Range("AC1").Value
Dim n_cargas As Integer
n_cargas = Range("AK1").Value
'Copiamos la matriz de rigidez completa
Worksheets("Matriz global de rigidez").Copy After:=Sheets(Sheets.Count)
Dim hoja As Worksheet
Set hoja = ActiveWorkbook.Sheets("Matriz global de rigidez (2)")
'La movemos al final
hoja.Activate
ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
Application.ScreenUpdating = True
'Le damos nombre
hoja.Name = "Matriz rigidez reducida"
'Copiamos todas las celdas escritas, y pegamos en el mismo area valores y formatos
Dim i As Integer
Dim j As Integer
i = 1
Do While i > 0
If Range(rango(1, i)).Value = "Fuerzas" Then
Exit Do
End If
i = i + 1
Loop
Range(rango(1, 1) & ":" & rango(i, i)).Copy
Range(rango(1, 1) & ":" & rango(i, i)).PasteSpecial xlPasteValues
Range(rango(1, 1) & ":" & rango(i, i)).PasteSpecial xlPasteFormats
'Borramos las columas de la derecha de las fuerzas
Dim k As Integer
k = i + 1
For j = (i + 1) To (i + n_cargas + 1)
Range(rango(1, k)).Select
Selection.EntireColumn.Delete
Next j
'Borramos las filas y las columnas que tengan desplazamientos y giros conocidos
Dim filas_borrar() As Integer
Dim inicio As Integer
Dim fila As Integer
Application.Sheets("Datos generales").Activate
For i = 0 To n_apoyos
If Range(rango((i + 2), 26)).Value <> "" Then 'Empieza definicion de apoyo
If Range(rango((i + 2), 27)).Value <> "" Then 'Define el nº de nodo
inicio = (CInt(Range(rango((i + 3), 27)).Value) * 6) - 6 + 2 'Empieza definicion de fila
For j = 1 To 6
If Not IsEmpty(Range(rango((i + 3), (27 + j)))) Then 'Apoyo definido, en este caso no distingue entre 0 y otro
valor
fila = inicio + j
If (i = 0) And (j = 1) Then
ReDim filas_borrar(0)
Else
ReDim Preserve filas_borrar(UBound(filas_borrar) + 1)
End If
filas_borrar(UBound(filas_borrar)) = fila
End If
Next j
End If
End If
Next i
Application.Sheets("Matriz rigidez reducida").Activate
For i = 0 To UBound(filas_borrar)
Range(rango(1, (filas_borrar(i) - i))).Select
Selection.EntireColumn.Delete
Range(rango((filas_borrar(i) - i), 1)).Select
Selection.EntireRow.Delete
Next i
UserForm1.Show
End Function
Public Function K_inversa()
Application.Sheets("Matriz rigidez reducida").Activate
Dim n_filas As Integer
Dim k As String
Dim i As Integer
n_filas = Application.CountA(Range("B1:B65536"))
Dim rang As String
rang = "C" & CStr(n_filas + 3) & ":" & rango(2 * n_filas, n_filas)
k = "=MINVERSE(R[-" & (n_filas) & "]C[]:R[-3]C[" & (n_filas - 3) & "])"
Range(rang).Select
Selection.FormulaArray = k
'Una vez termina el calculo de la matriz inversa colocamos los resultados
Dim col As Integer
col = n_filas + 5
Range(rango(n_filas + 2, col - 3)).Value = "Desplz"
Range(rango(n_filas + 2, col - 2)).Value = "Valor"
For i = 2 To n_filas - 1
Range(rango(n_filas + 1 + i, col - 3)).FormulaLocal = "=B" & i + 1
Next i
rang = rango(n_filas + 3, n_filas + 3) & ":" & rango(2 * n_filas, n_filas + 3)
k = "=MMULT(R[]C[" & (-n_filas) & "]:R[" & (n_filas - 3) & "]C[" & -3 & "],R[" & -n_filas & "]C[-2]:R[" & (-3) & "]C[-2])"
Range(rang).Select
Selection.FormulaArray = k
Range("A1").Select
'Una vez rellena la hoja, disminuyo zoom, deselecciono y la subo arriba del todo
ActiveWindow.Zoom = 55
Range("A1").Select
Application.CutCopyMode = False
End Function
Public Function Gauss_jordan()
Application.Sheets("Matriz rigidez reducida").Activate
Dim n_veces As Integer
Dim i As Integer
Dim k As Integer
Dim j As Integer
Dim fila As Integer
n_veces = Application.CountA(Range("A1:A65536")) - 1
Dim n_filas As Integer
n_filas = Application.CountA(Range("B1:B65536"))
'Hay que hacer el pivotamiento n_veces
For i = 1 To n_veces
fila = ((i * (n_veces + 2)) + 2)
Range(rango(fila, 3) & ":" & rango(fila, (n_veces + 3))).FormulaArray = "=" & rango((fila - n_veces - 1), 3) & ":" &
rango((fila - n_veces - 1), (n_veces + 3)) & "/" & rango((fila - n_veces - 1), (i + 2))
'Rellena las filas inferiores
For k = (fila + 1) To (n_veces + fila - i)
For j = 3 To n_veces + 3
Range(rango(k, j)).FormulaLocal = "=" & rango((k - n_veces - 1), j) & "-(" & _
rango((k - n_veces - 1), (i + 2)) & "*" & rango(fila, j) & ")"
Next j
Next k
'Rellena las filas superiores
For k = (fila - i + 1) To (fila - 1) 'Cdo i=1 no entra en el bucle..ok
For j = 3 To n_veces + 3
Range(rango(k, j)).FormulaLocal = "=" & rango((k - n_veces - 1), j) & "-(" & _
rango((k - n_veces - 1), (i + 2)) & "*" & rango(fila, j) & ")"
Next j
Next k
Next i
'Colocamos los resultados arriba a la derecha
'Una vez termina el calculo de la matriz inversa colocamos los resultados
Dim col As Integer
col = n_filas + 5
Range(rango(n_filas + 2, col - 3)).Value = "Desplz"
Range(rango(n_filas + 2, col - 2)).Value = "Valor"
For i = 2 To n_filas - 1
Range(rango(n_filas + 1 + i, col - 3)).FormulaLocal = "=B" & i + 1
Next i
Range(rango(n_filas + 3, col - 2) & ":" & rango((2 * n_filas), (col - 2))).FormulaArray = "=" & rango((fila - n_veces + 1),
(n_veces + 3)) & ":" & rango(fila, (n_veces + 3))
Range("A1").Select
'Una vez rellena la hoja, disminuyo zoom, deselecciono y la subo arriba del todo
ActiveWindow.Zoom = 55
Range("A1").Select
Application.CutCopyMode = False
End Function
Private Function ensambla_matriz_completa()
Application.Sheets("Datos generales").Activate
Dim n_elementos As Integer
Dim n_nodos As Integer
Dim n_cargas As Integer
Dim i As Integer
n_elementos = Range("H1").Value
n_nodos = Range("C1").Value
n_cargas = Range("AK1").Value
Dim array_cargas() As Carga
For i = 3 To n_cargas + 2
If i = 3 Then
ReDim array_cargas(0)
Else
ReDim Preserve array_cargas(UBound(array_cargas) + 1)
End If
array_cargas(UBound(array_cargas)).n = Sheets("Datos Generales").Range("AI" & i).Value
array_cargas(UBound(array_cargas)).en = Sheets("Datos Generales").Range("AJ" & i).Value
array_cargas(UBound(array_cargas)).id = Sheets("Datos Generales").Range("AK" & i).Value
array_cargas(UBound(array_cargas)).tipo = Sheets("Datos Generales").Range("AL" & i).Value
array_cargas(UBound(array_cargas)).sentido = Sheets("Datos Generales").Range("AM" & i).Value
array_cargas(UBound(array_cargas)).valor = Sheets("Datos Generales").Range("AN" & i).Value
array_cargas(UBound(array_cargas)).distancia = Sheets("Datos Generales").Range("AO" & i).Value
array_cargas(UBound(array_cargas)).hipotesis = Sheets("Datos Generales").Range("AP" & i).Value
Next i
'Genera una hoja nueva
Dim hoja As Worksheet
Set hoja = ActiveWorkbook.Sheets.Add
'La movemos al final
ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
Application.ScreenUpdating = True
'Le damos nombre
hoja.Name = "Matriz global de rigidez"
Range("B1").Value = "Columna"
Range("A2").Value = "Fila"
Range("B2").Value = "Nodos"
Dim j As Integer
Dim k As Integer
Dim nodo As String
j = 3
For i = 1 To n_nodos
nodo = Sheets("Datos generales").Range("A" & (i + 2)).Value
ActiveSheet.Cells(j, 2).FormulaLocal = "Despl.X_" & nodo
ActiveSheet.Cells(j + 1, 2).FormulaLocal = "Despl.Y_" & nodo
ActiveSheet.Cells(j + 2, 2).FormulaLocal = "Despl.Z_" & nodo
ActiveSheet.Cells(j + 3, 2).FormulaLocal = "Giro en X_" & nodo
ActiveSheet.Cells(j + 4, 2).FormulaLocal = "Giro en Y_" & nodo
ActiveSheet.Cells(j + 5, 2).FormulaLocal = "Giro en Z_" & nodo
For k = j To (j + 5)
'ActiveSheet.Cells(k, 2).FormulaLocal = "='Datos generales'!A" & CStr(i + 2)
ActiveSheet.Cells(2, k).FormulaLocal = "='Datos generales'!A" & CStr(i + 2)
ActiveSheet.Cells(1, k).FormulaR1C1 = "=(6*R[1]C)+" & (k - 2) & "-(6*R[1]C)"
'ActiveSheet.Cells(k, 1).FormulaR1C1 = "=(6*RC[1])+" & (k - 2) & "-(6*RC[1])"
ActiveSheet.Cells(k, 1).FormulaR1C1 = "=" & Range(rango(1, k))
Next k
j = k
Next i
ActiveSheet.Cells(1, k).Value = "Fuerzas"
Dim
Dim
Dim
Dim
Dim
Dim
Dim
For
formula As String
fila As Integer
columna As Integer
valor As Double
formula1 As String
cadena_barra As String
z As Integer
i = 3 To ((6 * n_nodos) + 2) 'filas
For j = 3 To ((6 * n_nodos) + 2) 'columnas
formula1 = ""
For k = 1 To n_elementos
cadena_barra = "Barra" & CStr(k)
formula = "INDICE(" & cadena_barra & "!C17:N28;COINCIDIR(" & rango(i, 1) & ";" & cadena_barra &
"!A17:A28;0);COINCIDIR(" & rango(1, j) & ";" & cadena_barra & "!C15:N15;0)))"
If k = 1 Then
formula1 = "=SI(ESERROR(" & formula & ";0;(" & formula & ")"
Else
formula1 = formula1 & "+ SI(ESERROR(" & formula & ";0;(" & formula & ")"
End If
Next k
Range(rango(i, j)).FormulaLocal = formula1
Next j
Next i
'Ensamablamos las fuerzas que provocan las cargas en las barras
For i = 3 To ((6 * n_nodos) + 2) 'filas
formula1 = ""
For k = 1 To n_elementos
cadena_barra = "Barra" & CStr(k)
On Local Error Resume Next
fila = Application.WorksheetFunction.Match(Range(rango(i, 1)).Value, Worksheets(cadena_barra).Range("A17:A28"), 0)
If Err <> 0 Then
formula = "0"
Err.Clear
Else
formula = "INDICE(" & cadena_barra & "!O17:O28;" & CStr(fila) & ";1)"
End If
Range(rango(i, j + k)).FormulaLocal = "=" & formula
If i = 3 Then
Range(rango(2, j + k)).Value = cadena_barra
End If
Next k
Next i
'Ensamablamos las fuerzas que provocan las cargas en los nodos
columna = 0
For i = 0 To UBound(array_cargas)
If array_cargas(i).en = "Nodo" Then
fila = (6 * (array_cargas(i).id - 1)) + 2
If array_cargas(i).sentido = "X" Then
fila = fila + 1
ElseIf array_cargas(i).sentido = "Y" Then
fila = fila + 2
ElseIf array_cargas(i).sentido = "Z" Then
fila = fila + 2
End If
valor = array_cargas(i).valor
If array_cargas(i).hipotesis = "Carga Permanente" Then
valor = valor * 1.35
ElseIf array_cargas(i).hipotesis = "Sobrecarga" Then
valor = valor * 1.5
End If
For z = 3 To ((6 * n_nodos) + 2)
Range(rango(z, j + columna + k)).Value = 0
Next z
Range(rango(2, j + columna + k)).Value = "Nodo " & array_cargas(i).id
formula = "=BUSCARV(" & array_cargas(i).n & ";'Datos Generales'!AI3:AN65536;6)"
Range(rango(fila, j + columna + k)).FormulaLocal = formula 'valor'=BUSCARV(0;'Datos generales'!AI3:AN50;6)
columna = columna + 1
End If
Next i
'Sumamos las cargas
Dim cargas_nodos As Integer
cargas_nodos = 0
For k = 0 To UBound(array_cargas)
If array_cargas(k).en = "Nodo" Then
cargas_nodos = cargas_nodos + 1
End If
Next k
For i = 3 To ((6 * n_nodos) + 2)
For z = 0 To (n_elementos + cargas_nodos - 1)
If z = 0 Then
formula = "=" & rango(i, (z + j + 1)) & "+"
ElseIf (z <> 0) And (z <> (n_elementos + cargas_nodos - 1)) Then
formula = formula & rango(i, (z + j + 1)) & "+"
ElseIf z = (n_elementos + cargas_nodos - 1) Then
formula = formula & rango(i, (z + j + 1))
End If
Next z
If Right(formula, 1) = "+" Then
formula = Left(formula, Len(formula) - 1)
End If
Range(rango(i, j)) = formula
ActiveSheet.Calculate
Next i
End Function
Private Function genera_hojas_barras()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim n_elementos As Integer
Dim n_nodos As Integer
Dim n_secciones As Integer
Dim n_materiales As Integer
Dim n_cargas As Integer
Dim n_apoyos As Integer
n_secciones = Range("T1").Value
n_materiales = Range("N1").Value
n_elementos = Range("H1").Value
n_nodos = Range("C1").Value
n_cargas = Range("AK1").Value
Dim array_cargas() As Carga
For i = 3 To n_cargas + 2
If i = 3 Then
ReDim array_cargas(0)
Else
ReDim Preserve array_cargas(UBound(array_cargas) + 1)
End If
array_cargas(UBound(array_cargas)).n = Sheets("Datos Generales").Range("AI" & i).Value
array_cargas(UBound(array_cargas)).en = Sheets("Datos Generales").Range("AJ" & i).Value
array_cargas(UBound(array_cargas)).id = Sheets("Datos Generales").Range("AK" & i).Value
array_cargas(UBound(array_cargas)).tipo = Sheets("Datos Generales").Range("AL" & i).Value
array_cargas(UBound(array_cargas)).sentido = Sheets("Datos Generales").Range("AM" & i).Value
array_cargas(UBound(array_cargas)).valor = Sheets("Datos Generales").Range("AN" & i).Value
array_cargas(UBound(array_cargas)).distancia = Sheets("Datos Generales").Range("AO" & i).Value
array_cargas(UBound(array_cargas)).hipotesis = Sheets("Datos Generales").Range("AP" & i).Value
Next i
Dim hoja As Worksheet
For i = 1 To n_elementos
'Genera una hoja nueva
Set hoja = ActiveWorkbook.Sheets.Add
'La movemos al final
ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
Application.ScreenUpdating = True
'Le damos nombre
hoja.Name = "Barra" & i
'Rellenamos las casillas
Range("B1").Value = "Sección"
Range("B2").Value = "Material"
Range("B3").Value = "L"
Range("B4").Value = "A"
Range("B5").Value = "Iz"
Range("B6").Value = "Iy"
Range("B7").Value = "J"
Range("B8").Value = "E"
Range("B9").Value = "mod.Poisson"
Range("B10").Value = "G"
Range("B11").Value = "Coef.Dilatación"
Range("B11").HorizontalAlignment = xlHAlignRight
Range("K6").Value
Range("K7").Value
Range("K8").Value
Range("K9").Value
Range("M7").Value
Range("M8").Value
Range("M9").Value
=
=
=
=
=
=
=
"Cálculo de tensiones"
"Límite elástico"
"Wz"
"Wy"
"MPa"
"mm3"
"mm3"
Range("D3").Value = "mm"
Range("D4").Value = "mm2"
Range("D5").Value = "mm4"
Range("D6").Value = "mm4"
Range("D7").Value = "mm4"
Range("D8").Value = "MPa"
Range("D10").Value = "MPa"
Range("F3").FormulaLocal = "='Datos generales'!G" & CStr(i + 2)
Range("F4").FormulaLocal = "='Datos generales'!H" & CStr(i + 2)
Range("G3").FormulaLocal = "=BUSCARV(F3;'Datos generales'!A3:D" & (n_nodos + 2) & ";2)"
Range("H3").FormulaLocal = "=BUSCARV(F3;'Datos generales'!A3:D" & (n_nodos + 2) & ";3)"
Range("I3").FormulaLocal = "=BUSCARV(F3;'Datos generales'!A3:D" & (n_nodos + 2) & ";4)"
Range("G3").HorizontalAlignment = xlHAlignCenter
Range("H3").HorizontalAlignment = xlHAlignCenter
Range("I3").HorizontalAlignment = xlHAlignCenter
Range("G4").FormulaLocal = "=BUSCARV(F4;'Datos generales'!A3:D" & (n_nodos + 2) & ";2)"
Range("H4").FormulaLocal = "=BUSCARV(F4;'Datos generales'!A3:D" & (n_nodos + 2) & ";3)"
Range("I4").FormulaLocal = "=BUSCARV(F4;'Datos generales'!A3:D" & (n_nodos + 2) & ";4)"
Range("G4").HorizontalAlignment = xlHAlignCenter
Range("H4").HorizontalAlignment = xlHAlignCenter
Range("I4").HorizontalAlignment = xlHAlignCenter
Range("C1").FormulaLocal = "='Datos generales'!I" & CStr(i + 2)
Range("C2").FormulaLocal = "='Datos generales'!J" & CStr(i + 2)
Range("C3").FormulaLocal = "=RAIZ(((G4-G3)^2)+((H4-H3)^2)+((I4-I3)^2))"
Range("C4").FormulaLocal = "=BUSCARV(C1;'Datos generales'!R3:X" & (n_secciones + 2) & ";2)"
Range("C5").FormulaLocal = "=BUSCARV(C1;'Datos generales'!R3:X" & (n_secciones + 2) & ";3)"
Range("C6").FormulaLocal = "=BUSCARV(C1;'Datos generales'!R3:X" & (n_secciones + 2) & ";4)"
Range("C7").FormulaLocal = "=BUSCARV(C1;'Datos generales'!R3:X" & (n_secciones + 2) & ";5)"
Range("C8").FormulaLocal = "=BUSCARV(C1;'Datos generales'!L3:P" & (n_materiales + 2) & ";2)"
Range("C9").FormulaLocal = "=BUSCARV(C1;'Datos generales'!L3:P" & (n_materiales + 2) & ";3)"
Range("C11").FormulaLocal = "=BUSCARV(C1;'Datos generales'!L3:P" & (n_materiales + 2) & ";4)"
Range("L7").FormulaLocal = "=BUSCARV(C1;'Datos generales'!L3:P" & (n_materiales + 2) & ";5)"
Range("L8").FormulaLocal = "=BUSCARV(C1;'Datos generales'!R3:X" & (n_secciones + 2) & ";6)"
Range("L9").FormulaLocal = "=BUSCARV(C1;'Datos generales'!R3:X" & (n_secciones + 2) & ";7)"
Range("C10").FormulaLocal = "=C8/(2*(1+C9))"
Range("F2").Value = "Coordenadas nodos"
Range("F2").HorizontalAlignment = xlHAlignRight
Range("G2").Value = "X"
Range("G2").HorizontalAlignment = xlHAlignCenter
Range("H2").Value = "Y"
Range("H2").HorizontalAlignment = xlHAlignCenter
Range("I2").Value = "Z"
Range("I2").HorizontalAlignment = xlHAlignCenter
Range("K2").Value = "Mxy"
Range("K2").HorizontalAlignment = xlHAlignCenter
Range("L2").Value = "Mzx"
Range("L2").HorizontalAlignment = xlHAlignCenter
Range("M2").Value = "Mzy"
Range("M2").HorizontalAlignment = xlHAlignCenter
Range("K3").FormulaLocal = "=RAIZ(((G4-G3)^2)+((H4-H3)^2))"
Range("L3").FormulaLocal = "=RAIZ(((G4-G3)^2)+((I4-I3)^2))"
Range("M3").FormulaLocal = "=RAIZ(((I4-I3)^2)+((H4-H3)^2))"
Range("K3").HorizontalAlignment = xlHAlignCenter
Range("L3").HorizontalAlignment = xlHAlignCenter
Range("M3").HorizontalAlignment = xlHAlignCenter
Range("F6").Value = "Giros en torno a ejes"
Range("F6").HorizontalAlignment = xlHAlignRight
Range("G6").Value = "X"
Range("G6").HorizontalAlignment = xlHAlignCenter
Range("H6").Value = "Y"
Range("H6").HorizontalAlignment = xlHAlignCenter
Range("I6").Value = "Z"
Range("I6").HorizontalAlignment = xlHAlignCenter
Range("F7").Value = "Radianes"
Range("F8").Value = "Grados"
Range("G7").FormulaLocal = "=SI(M3<>0;(SI((GRADOS(2*PI())-ASENO((I4-I3)/M3))=360;0;(2*PI())-ASENO((I4-I3)/M3)));0)"
Range("H7").FormulaLocal = "=SI(L3<>0;(SI((GRADOS(2*PI())-ASENO((I4-I3)/L3))=360;0;(2*PI())-ASENO((I4-I3)/L3)));0)"
Range("I7").FormulaLocal = "=SI(K3<>0;(SI((GRADOS(2*PI())-ASENO((H4-H3)/K3))=360;0;(2*PI())-ASENO((H4-H3)/K3)));0)"
Range("G7").HorizontalAlignment = xlHAlignCenter
Range("H7").HorizontalAlignment = xlHAlignCenter
Range("I7").HorizontalAlignment = xlHAlignCenter
Range("G8").FormulaLocal = "=GRADOS(G7)"
Range("H8").FormulaLocal = "=GRADOS(H7)"
Range("I8").FormulaLocal = "=GRADOS(I7)"
Range("G8").HorizontalAlignment = xlHAlignCenter
Range("H8").HorizontalAlignment = xlHAlignCenter
Range("I8").HorizontalAlignment = xlHAlignCenter
Range("C59").Value = "Ralfa"
Range("C64").Value = "Rbeta"
Range("C69").Value = "Rgamma"
Range("C60").Value = 1
Range("D60").Value = 0
Range("E60").Value = 0
Range("C61").Value = 0
Range("D61").FormulaLocal
Range("E61").FormulaLocal
Range("C62").Value = 0
Range("D62").FormulaLocal
Range("E62").FormulaLocal
Range("C66").Value = 0
Range("D66").Value = 1
Range("E66").Value = 0
Range("D65").Value = 0
Range("C65").FormulaLocal
Range("E65").FormulaLocal
Range("D67").Value = 0
Range("C67").FormulaLocal
Range("E67").FormulaLocal
Range("C72").Value = 0
Range("D72").Value = 0
Range("E72").Value = 1
Range("E71").Value = 0
Range("D71").FormulaLocal
Range("C71").FormulaLocal
Range("E70").Value = 0
Range("D70").FormulaLocal
Range("C70").FormulaLocal
= "=COS(RADIANES(G8))"
= "=-SENO(RADIANES(G8))"
= "=SENO(RADIANES(G8))"
= "=COS(RADIANES(G8))"
= "=COS(RADIANES(H8))"
= "=SENO(RADIANES(H8))"
= "=-SENO(RADIANES(H8))"
= "=COS(RADIANES(H8))"
= "=COS(RADIANES(I8))"
= "=SENO(RADIANES(I8))"
= "=-SENO(RADIANES(I8))"
= "=COS(RADIANES(I8))"
Range("G59").Value = "Ralfa*Rbeta"
Range("G64").Value = "Ralfa*Rbeta*Rgamma"
Range("G60:I62").Select
Selection.FormulaArray = "=MMULT(RC[-4]:R[2]C[-2],R[5]C[-4]:R[7]C[-2])" 'RC[-4]...misma fila, columna, la que estamos -4
Range("G65:I67").Select
Selection.FormulaArray = "=MMULT(R[-5]C:R[-3]C[2],R[5]C[-4]:R[7]C[-2])"
Range("C45").Value = "Matriz de giro T"
Range("C46:E48").Select
Selection.FormulaArray = "=(R[19]C[4]:R[21]C[6])"
Range("F49:H51").Select
Selection.FormulaArray = "=(R[-3]C[-3]:R[-1]C[-1])"
Range("I52:K54").Select
Selection.FormulaArray = "=(R[-3]C[-3]:R[-1]C[-1])"
Range("L55:N57").Select
Selection.FormulaArray = "=(R[-3]C[-3]:R[-1]C[-1])"
Range("F46:N48").Select
Selection.FormulaArray = "=0"
Range("I49:N51").Select
Selection.FormulaArray = "=0"
Range("L52:N54").Select
Selection.FormulaArray = "=0"
Range("C55:K57").Select
Selection.FormulaArray = "=0"
Range("C52:H54").Select
Selection.FormulaArray = "=0"
Range("C49:E51").Select
Selection.FormulaArray = "=0"
Range("P45").Value = "Traspuesta de la matriz de giro"
Range("P46:AA57").Select
Selection.FormulaArray = "=TRANSPOSE(RC[-13]:R[11]C[-2])"
Range("B30").Value = "Locales"
Range("B31").Value = "Barra " & i
Range("C32").FormulaLocal
Range("C33").FormulaLocal
Range("C34").FormulaLocal
Range("C35").FormulaLocal
Range("C36").FormulaLocal
Range("C37").FormulaLocal
Range("C38").FormulaLocal
Range("C39").FormulaLocal
Range("C40").FormulaLocal
Range("C41").FormulaLocal
Range("C42").FormulaLocal
Range("C43").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
"=C8*C4/C3"
0
0
0
0
0
"=-C8*C4/C3"
0
0
0
0
0
Range("D32").FormulaLocal
Range("D33").FormulaLocal
Range("D34").FormulaLocal
Range("D35").FormulaLocal
Range("D36").FormulaLocal
Range("D37").FormulaLocal
Range("D38").FormulaLocal
Range("D39").FormulaLocal
Range("D40").FormulaLocal
Range("D41").FormulaLocal
Range("D42").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
0
"=12*C8*C5/(C3^3)"
0
0
0
"=6*C8*C5/(C3^2)"
0
"=-12*C8*C5/(C3^3)"
0
0
0
Range("D43").FormulaLocal = "=6*C8*C5/(C3^2)"
Range("E32").FormulaLocal
Range("E33").FormulaLocal
Range("E34").FormulaLocal
Range("E35").FormulaLocal
Range("E36").FormulaLocal
Range("E37").FormulaLocal
Range("E38").FormulaLocal
Range("E39").FormulaLocal
Range("E40").FormulaLocal
Range("E41").FormulaLocal
Range("E42").FormulaLocal
Range("E43").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
0
0
"=12*C8*C6/(C3^3)"
0
"=-6*C8*C6/(C4^2)"
0
0
0
"=-12*C8*C6/(C3^3)"
0
"=-6*C8*C6/(C4^2)"
0
Range("F32").FormulaLocal
Range("F33").FormulaLocal
Range("F34").FormulaLocal
Range("F35").FormulaLocal
Range("F36").FormulaLocal
Range("F37").FormulaLocal
Range("F38").FormulaLocal
Range("F39").FormulaLocal
Range("F40").FormulaLocal
Range("F41").FormulaLocal
Range("F42").FormulaLocal
Range("F43").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
0
0
0
"=C10*C7/C3"
0
0
0
0
0
"=-C10*C7/C3"
0
0
Range("G32").FormulaLocal
Range("G33").FormulaLocal
Range("G34").FormulaLocal
Range("G35").FormulaLocal
Range("G36").FormulaLocal
Range("G37").FormulaLocal
Range("G38").FormulaLocal
Range("G39").FormulaLocal
Range("G40").FormulaLocal
Range("G41").FormulaLocal
Range("G42").FormulaLocal
Range("G43").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
0
0
"=-6*C8*C6/(C4^2)"
0
"=4*C8*C6/C3"
0
0
0
"=6*C8*C6/(C4^2)"
0
"=2*C8*C6/C3"
0
Range("H32").FormulaLocal
Range("H33").FormulaLocal
Range("H34").FormulaLocal
Range("H35").FormulaLocal
Range("H36").FormulaLocal
Range("H37").FormulaLocal
Range("H38").FormulaLocal
Range("H39").FormulaLocal
Range("H40").FormulaLocal
Range("H41").FormulaLocal
Range("H42").FormulaLocal
Range("H43").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
0
"=6*C8*C5/(C3^2)"
0
0
0
"=4*C8*C5/C3"
0
"=-6*C8*C5/(C3^2)"
0
0
0
"=2*C8*C5/C3"
Range("I32").FormulaLocal
Range("I33").FormulaLocal
Range("I34").FormulaLocal
Range("I35").FormulaLocal
Range("I36").FormulaLocal
Range("I37").FormulaLocal
Range("I38").FormulaLocal
Range("I39").FormulaLocal
Range("I40").FormulaLocal
Range("I41").FormulaLocal
Range("I42").FormulaLocal
Range("I43").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
"=-C8*C4/C3"
0
0
0
0
0
"=C8*C4/C3"
0
0
0
0
0
Range("J32").FormulaLocal
Range("J33").FormulaLocal
Range("J34").FormulaLocal
Range("J35").FormulaLocal
Range("J36").FormulaLocal
Range("J37").FormulaLocal
Range("J38").FormulaLocal
Range("J39").FormulaLocal
Range("J40").FormulaLocal
Range("J41").FormulaLocal
Range("J42").FormulaLocal
Range("J43").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
0
"=-12*C8*C5/(C3^3)"
0
0
0
"=-6*C8*C5/(C3^2)"
0
"=12*C8*C5/(C3^3)"
0
0
0
"=-6*C8*C5/(C3^2)"
Range("K32").FormulaLocal
Range("K33").FormulaLocal
Range("K34").FormulaLocal
Range("K35").FormulaLocal
Range("K36").FormulaLocal
Range("K37").FormulaLocal
Range("K38").FormulaLocal
Range("K39").FormulaLocal
Range("K40").FormulaLocal
Range("K41").FormulaLocal
Range("K42").FormulaLocal
Range("K43").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
0
0
"=-12*C8*C6/(C3^3)"
0
"=6*C8*C6/(C4^2)"
0
0
0
"=12*C8*C6/(C3^3)"
0
"=6*C8*C6/(C4^2)"
0
Range("L32").FormulaLocal
Range("L33").FormulaLocal
Range("L34").FormulaLocal
Range("L35").FormulaLocal
Range("L36").FormulaLocal
Range("L37").FormulaLocal
Range("L38").FormulaLocal
Range("L39").FormulaLocal
Range("L40").FormulaLocal
Range("L41").FormulaLocal
Range("L42").FormulaLocal
Range("L43").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
0
0
0
"=-C10*C7/C3"
0
0
0
0
0
"=C10*C7/C3"
0
0
Range("M32").FormulaLocal
Range("M33").FormulaLocal
Range("M34").FormulaLocal
Range("M35").FormulaLocal
Range("M36").FormulaLocal
Range("M37").FormulaLocal
Range("M38").FormulaLocal
Range("M39").FormulaLocal
Range("M40").FormulaLocal
Range("M41").FormulaLocal
Range("M42").FormulaLocal
Range("M43").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
0
0
"=-6*C8*C6/(C4^2)"
0
"=2*C8*C6/C3"
0
0
0
"=6*C8*C6/(C4^2)"
0
"=4*C8*C6/C3"
0
Range("N32").FormulaLocal
Range("N33").FormulaLocal
Range("N34").FormulaLocal
Range("N35").FormulaLocal
Range("N36").FormulaLocal
Range("N37").FormulaLocal
Range("N38").FormulaLocal
Range("N39").FormulaLocal
Range("N40").FormulaLocal
Range("N41").FormulaLocal
Range("N42").FormulaLocal
Range("N43").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
0
"=6*C8*C5/(C3^2)"
0
0
0
"=2*C8*C5/C3"
0
"=-6*C8*C5/(C3^2)"
0
0
0
"=4*C8*C5/C3"
Range("P31").Value = "GIRO_T
x
K_locales"
Range("P32:AA43").Select
Selection.FormulaArray = "=MMULT(R[14]C:R[25]C[11],RC[-13]:R[11]C[-2])"
Range("B14").Value = "Globales = GIRO_T x K_locales x GIRO"
Range("C17:N28").Select
Selection.FormulaArray = "=MMULT(R[15]C[13]:R[26]C[24],R[29]C:R[40]C[11])"
Range("B16").Value = "Nº de
Range("C16").FormulaLocal =
Range("D16").FormulaLocal =
Range("E16").FormulaLocal =
Range("F16").FormulaLocal =
Range("G16").FormulaLocal =
Range("H16").FormulaLocal =
Range("I16").FormulaLocal =
Range("J16").FormulaLocal =
Range("K16").FormulaLocal =
Range("L16").FormulaLocal =
Range("M16").FormulaLocal =
Range("N16").FormulaLocal =
nodo"
"=F3"
"=F3"
"=F3"
"=F3"
"=F3"
"=F3"
"=F4"
"=F4"
"=F4"
"=F4"
"=F4"
"=F4"
Dim nudo1 As String
Dim nudo2 As String
nudo1 = Range("F3").Value
nudo2 = Range("F4").Value
Range("B17").Value = "Despl.X_" & nudo1
Range("B18").Value
Range("B19").Value
Range("B20").Value
Range("B21").Value
Range("B22").Value
Range("B23").Value
Range("B24").Value
Range("B25").Value
Range("B26").Value
Range("B27").Value
Range("B28").Value
=
=
=
=
=
=
=
=
=
=
=
"Despl.Y_" &
"Despl.Z_" &
"Giro en X_"
"Giro en Y_"
"Giro en Z_"
"Despl.X_" &
"Despl.Y_" &
"Despl.Z_" &
"Giro en X_"
"Giro en Y_"
"Giro en Z_"
nudo1
nudo1
& nudo1
& nudo1
& nudo1
nudo2
nudo2
nudo2
& nudo2
& nudo2
& nudo2
Range("B15").Value = "Columnas"
Range("A16").Value = "Filas"
Range("C15").FormulaLocal
Range("D15").FormulaLocal
Range("E15").FormulaLocal
Range("F15").FormulaLocal
Range("G15").FormulaLocal
Range("H15").FormulaLocal
Range("I15").FormulaLocal
Range("J15").FormulaLocal
Range("K15").FormulaLocal
Range("L15").FormulaLocal
Range("M15").FormulaLocal
Range("N15").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
"=(6*F3)-5"
"=(6*F3)-4"
"=(6*F3)-3"
"=(6*F3)-2"
"=(6*F3)-1"
"=(6*F3)"
"=(6*F4)-5"
"=(6*F4)-4"
"=(6*F4)-3"
"=(6*F4)-2"
"=(6*F4)-1"
"=(6*F4)"
Range("A17").FormulaLocal
Range("A18").FormulaLocal
Range("A19").FormulaLocal
Range("A20").FormulaLocal
Range("A21").FormulaLocal
Range("A22").FormulaLocal
Range("A23").FormulaLocal
Range("A24").FormulaLocal
Range("A25").FormulaLocal
Range("A26").FormulaLocal
Range("A27").FormulaLocal
Range("A28").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
"=(6*F3)-5"
"=(6*F3)-4"
"=(6*F3)-3"
"=(6*F3)-2"
"=(6*F3)-1"
"=(6*F3)"
"=(6*F4)-5"
"=(6*F4)-4"
"=(6*F4)-3"
"=(6*F4)-2"
"=(6*F4)-1"
"=(6*F4)"
Range("O2").Value
Range("O3").Value
Range("P3").Value
Range("Q3").Value
Range("R3").Value
Range("S3").Value
Range("T3").Value
=
=
=
=
=
=
=
Range("R15").Value
Range("Q17").Value
Range("Q18").Value
Range("Q19").Value
"Fuerzas locales"
"n"
"Tipo"
"Sentido"
"Valor"
"Distancia"
"Hipótesis"
=
=
=
=
"Fuerzas locales"
"Axil"
"Vy"
"Vz"
Range("Q20").Value
Range("Q21").Value
Range("Q22").Value
Range("Q23").Value
Range("Q24").Value
Range("Q25").Value
Range("Q26").Value
Range("Q27").Value
Range("Q28").Value
=
=
=
=
=
=
=
=
=
"Torsor"
"My"
"Mz"
"Axil"
"Vy"
"Vz"
"Torsor"
"My"
"Mz"
k = 4
For j = 0 To UBound(array_cargas)
If array_cargas(j).en = "Barra" Then
If array_cargas(j).id = i Then
Range("O" & k).Value = array_cargas(j).n
Range("P" & k).FormulaLocal = "=BUSCARV(O"
Range("Q" & k).FormulaLocal = "=BUSCARV(O"
Range("R" & k).FormulaLocal = "=BUSCARV(O"
Range("S" & k).FormulaLocal = "=BUSCARV(O"
Range("T" & k).FormulaLocal = "=BUSCARV(O"
&
&
&
&
&
k
k
k
k
k
&
&
&
&
&
";'Datos
";'Datos
";'Datos
";'Datos
";'Datos
generales'!AI3:AP"
generales'!AI3:AP"
generales'!AI3:AP"
generales'!AI3:AP"
generales'!AI3:AP"
&
&
&
&
&
(n_cargas
(n_cargas
(n_cargas
(n_cargas
(n_cargas
+
+
+
+
+
2)
2)
2)
2)
2)
&
&
&
&
&
";4)"
";5)"
";6)"
";7)"
";8)"
Range(rango(17, 14 + k)).FormulaLocal = "=SI(Q" & k & "=" & Chr(34) & "X" & Chr(34) & ";SI(P" & k & "=" & Chr(34)
& "Distribuida" & Chr(34) & ";(0,5*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "=" & Chr(34) &
"Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "*C3);(0,5*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "="
& Chr(34) & "Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "));0)"
Range(rango(18, 14 + k)).FormulaLocal = "=SI(Q" & k & "=" & Chr(34) & "Y" & Chr(34) & ";SI(P" & k & "=" & Chr(34)
& "Distribuida" & Chr(34) & ";(0,5*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "=" & Chr(34) &
"Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "*C3);((1-S" & k & ")*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) &
";1;SI(T" & k & "=" & Chr(34) & "Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "));0)"
Range(rango(19, 14 + k)).FormulaLocal = "=SI(Q" & k & "=" & Chr(34) & "Z" & Chr(34) & ";SI(P" & k & "=" & Chr(34)
& "Distribuida" & Chr(34) & ";(0,5*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "=" & Chr(34) &
"Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "*C3);((1-S" & k & ")*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) &
";1;SI(T" & k & "=" & Chr(34) & "Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "));0)"
Range(rango(20, 14 + k)).Value = 0
Range(rango(21, 14 + k)).FormulaLocal = "=SI(Q" & k & "=" & Chr(34) & "Z" & Chr(34) & ";SI(P" & k & "=" & Chr(34)
& "Distribuida" & Chr(34) & ";(1*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "=" & Chr(34) & "Sobrecarga"
& Chr(34) & ";1,5;1,35)))*R" & k & "*(C3^2)/12);(1*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "=" &
Chr(34) & "Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "*S" & k & "*((1-S" & k & ")^2)*C3));0)"
Range(rango(22, 14 + k)).FormulaLocal = "=SI(Q" & k & "=" & Chr(34) & "Y" & Chr(34) & ";SI(P" & k & "=" & Chr(34)
& "Distribuida" & Chr(34) & ";(1*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "=" & Chr(34) & "Sobrecarga"
& Chr(34) & ";1,5;1,35)))*R" & k & "*(C3^2)/12);(1*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "=" &
Chr(34) & "Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "*S" & k & "*((1-S" & k & ")^2)*C3));0)"
Range(rango(23, 14 + k)).FormulaLocal = "=SI(Q" & k & "=" & Chr(34) & "X" & Chr(34) & ";SI(P" & k & "=" & Chr(34)
& "Distribuida" & Chr(34) & ";(0,5*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "=" & Chr(34) &
"Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "*C3);(0,5*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "="
& Chr(34) & "Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "));0)"
Range(rango(24, 14 + k)).FormulaLocal = "=SI(Q" & k & "=" & Chr(34) & "Y" & Chr(34) & ";SI(P" & k & "=" & Chr(34)
& "Distribuida" & Chr(34) & ";(0,5*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "=" & Chr(34) &
"Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "*C3);((S" & k & ")*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T"
& k & "=" & Chr(34) & "Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "));0)"
Range(rango(25, 14 + k)).FormulaLocal = "=SI(Q" & k & "=" & Chr(34) & "Z" & Chr(34) & ";SI(P" & k & "=" & Chr(34)
& "Distribuida" & Chr(34) & ";(0,5*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "=" & Chr(34) &
"Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "*C3);((S" & k & ")*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T"
& k & "=" & Chr(34) & "Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "));0)"
Range(rango(26, 14 + k)).Value = 0
Range(rango(27, 14 + k)).FormulaLocal = "=SI(Q" & k & "=" & Chr(34) & "Z" & Chr(34) & ";SI(P" & k & "=" & Chr(34)
& "Distribuida" & Chr(34) & ";(-1*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "=" & Chr(34) & "Sobrecarga"
& Chr(34) & ";1,5;1,35)))*R" & k & "*(C3^2)/12);(-1*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "=" &
Chr(34) & "Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "*(S" & k & "^2)*(1-S" & k & ")*C3));0)"
Range(rango(28, 14 + k)).FormulaLocal = "=SI(Q" & k & "=" & Chr(34) & "Y" & Chr(34) & ";SI(P" & k & "=" & Chr(34)
& "Distribuida" & Chr(34) & ";(-1*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "=" & Chr(34) & "Sobrecarga"
& Chr(34) & ";1,5;1,35)))*R" & k & "*(C3^2)/12);(-1*(SI(T" & k & "=" & Chr(34) & "Sin mayorar" & Chr(34) & ";1;SI(T" & k & "=" &
Chr(34) & "Sobrecarga" & Chr(34) & ";1,5;1,35)))*R" & k & "*(S" & k & "^2)*(1-S" & k & ")*C3));0)"
k = k + 1
End If
End If
Next j
Range("O3:T14").HorizontalAlignment = xlHAlignCenter
If (14 + k - 1) > 18 Then
Range(rango(17, 14 + k) & ":" & rango(28, 14 + k)).FormulaArray = "=" & rango(17, 18) & ":" & rango(28, 18) & "+" &
rango(17, (14 + k - 1)) & ":" & rango(28, (14 + k - 1))
Else
Range(rango(17, 14 + k) & ":" & rango(28, 14 + k)).FormulaArray = "=" & rango(17, 18) & ":" & rango(28, 18)
End If
Range(rango(16, 14 + k)).Value = "Totales"
Range(rango(16, 14 + k + 1)).Value = "GIRO_T
x
F_locales"
Range(rango(17, 14 + k + 1) & ":" & rango(28, 14 + k + 1)).FormulaArray = "=MMULT(P46:AA57," & rango(17, 14 + k) & ":" &
rango(28, 14 + k) & ")"
Range("O15").Value = "Fuerzas"
Range("O17:O28").FormulaArray = "=" & rango(17, 14 + k + 1) & ":" & rango(28, 14 + k + 1)
Next i
End Function
Option Explicit
Private Type Nudo
n As String
x As Double
y As Double
'Z As Double
End Type
Private Type elemento
n As String
nudos(0 To 2) As String
End Type
Private Type elementoR
n As String
nudos(0 To 3) As String
End Type
Private Type restriccion
nodos As String 'cadena de nodos con la misma restriccion
End Type
Private Type carga
nodo As String
valor_X As Single
valor_Y As Single
End Type
Private Type Tipo_punto
x As Double
y As Double
End Type
Dim elementosR() As elementoR
Dim elementos() As elemento
Dim nodos() As Nudo
Private Sub Archivo_boton_Click()
CommonDialog1.Filter = "INP Files (*.inp)|*.inp|"
CommonDialog1.FilterIndex = 1
CommonDialog1.DialogTitle = "Guarda INP"
CommonDialog1.InitDir = "c:\"
CommonDialog1.FileName = "FEM_rafa"
CommonDialog1.ShowSave
Dim ruta As String
ruta = CommonDialog1.FileName
TextBox1.Text = ruta
End Sub
Private Sub Sel_y_exp_boton_Click()
If Option_triangulo.Value = True Then
Triangulares
ElseIf Option_rectangular.Value = True Then
Rectangulares
End If
End Sub
Private Sub Rectangulares()
UserForm1.Hide
Dim cont As Integer
For cont = 0 To ThisDrawing.Layers.Count - 1
ThisDrawing.Layers(cont).LayerOn = True
Next cont
Dim ss As AcadSelectionSet
Dim nombre As String
'nombre = "zz"
nombre = Chr(Int(Rnd * 26) + 65) & Chr(Int(Rnd * 26) + 65)
For cont = 0 To ThisDrawing.SelectionSets.Count - 1
If ThisDrawing.SelectionSets(cont).Name = nombre Then
ThisDrawing.SelectionSets(cont).Delete
End If
Next
Set ss = ThisDrawing.SelectionSets.Add(nombre)
ss.SelectOnScreen
Dim cont1, cont2 As Integer
Dim n_vertices As Integer
Dim objEnt As AcadEntity
Dim varCords As Variant
Dim aux As Variant
Dim n_elemento As Integer
n_elemento = 0
Dim n_restriccion As Integer
n_restriccion = 0
Dim n_carga As Integer
n_carga = 0
Dim varAtributos As Variant
Dim distancia As Single
Dim angulo As Double
Dim carga As String
Dim max_n_nodos As Integer
Dim ucsObj As AcadUCS
Dim textObj As AcadText
Dim textString As String
Dim insertionPoint(0 To 2) As Double
Dim restricciones(0 To 1) As restriccion
Dim cargas() As carga
max_n_nodos = 0
ReDim nodos(0)
ReDim elementosR(0)
Dim objetos_explotados As Variant
Dim nodo_aux As String
For cont1 = 1 To ss.Count
Set objEnt = ss.Item(cont1 - 1)
'Si la capa es de elementos
If objEnt.Layer = "Elementos" Or objEnt.Layer = "elementos" Then
If (objEnt.ObjectName = "AcDb3dPolyline") Or (objEnt.ObjectName = "IAcad3DPolyline") Then 'Tienen
coordenadas de altura
varCords = objEnt.Coordinates
ElseIf (objEnt.ObjectName = "AcDbPolyline") Or (objEnt.ObjectName = "IAcadLWPolyline") Then
varCords = objEnt.Coordinates
End If
Dim encontrado As Boolean
Dim existe_capa As Boolean
Dim acCapa As AcadLayer
Dim acCapa2 As AcadLayer
Dim color As AcadAcCmColor
Dim i As Integer
'Añadimos los nodos
For cont2 = 0 To UBound(varCords)
If (cont2 Mod 2) = 0 Then
If nodos(0).n = "" Then 'Es el primer nodo añadido
nodos(0).n = CStr(UBound(nodos)) + 1
nodos(0).x = varCords(cont2)
nodos(0).y = varCords(cont2 + 1)
'nodos(0).Z = varCords(cont2 + 2)
'Vemos si existe la capa de etiquetas y si no la creamos
existe_capa = False
For i = 0 To ThisDrawing.Layers.Count - 1
If ThisDrawing.Layers(i).Name = "Etiqueta_nodos" Then
existe_capa = True
Exit For
End If
Next i
If existe_capa = False Then
Set acCapa = ThisDrawing.Layers.Add("Etiqueta_nodos")
Set color = New AcadAcCmColor
With color
.ColorMethod = acColorMethodByACI
.ColorIndex = 3
End With
acCapa.TrueColor = color
Else
Set acCapa = ThisDrawing.Layers("Etiqueta_nodos")
End If
'Activamos la capa
ThisDrawing.ActiveLayer = acCapa
'Insertamos texto con el nº de elemento
textString = nodos(0).n
insertionPoint(0) = nodos(0).x
insertionPoint(1) = nodos(0).y
insertionPoint(2) = 0
Set textObj = ThisDrawing.ModelSpace. _
AddText(textString, insertionPoint, 0.01)
Else 'No es el primer nodo, por lo que lo deberemos buscar entre los existentes y añadirlo si no
existe
encontrado = False
For cont = 0 To UBound(nodos)
If (Abs(varCords(cont2) - nodos(cont).x) < 0.00001) And (Abs(varCords(cont2 + 1) nodos(cont).y) < 0.00001) Then
encontrado = True
Exit For
End If
Next cont
If encontrado = False Then
ReDim Preserve nodos(UBound(nodos) + 1)
nodos(UBound(nodos)).n = UBound(nodos) + 1
nodos(UBound(nodos)).x = varCords(cont2)
nodos(UBound(nodos)).y = varCords(cont2 + 1)
'nodos(UBound(nodos)).Z = varCords(cont2 + 2)
'Activamos la capa
ThisDrawing.ActiveLayer = acCapa
'Insertamos texto con el nº de elemento
textString = nodos(UBound(nodos)).n
insertionPoint(0) = nodos(UBound(nodos)).x
insertionPoint(1) = nodos(UBound(nodos)).y
insertionPoint(2) = 0
Set textObj = ThisDrawing.ModelSpace. _
AddText(textString, insertionPoint, 0.01)
End If
End If
End If
Next cont2
'Añadimos los elementosR
If elementosR(0).n = "" Then 'Es el primer elemento añadido
ReDim elementosR(0)
Else 'No es el primer elemento
ReDim Preserve elementosR(UBound(elementosR) + 1)
End If
elementosR(UBound(elementosR)).n = CStr(UBound(elementosR)) + 1
elementosR(UBound(elementosR)).nudos(0) = N_nudo(varCords(0), varCords(1))
elementosR(UBound(elementosR)).nudos(1) = N_nudo(varCords(2), varCords(3))
elementosR(UBound(elementosR)).nudos(2) = N_nudo(varCords(4), varCords(5))
elementosR(UBound(elementosR)).nudos(3) = N_nudo(varCords(6), varCords(7))
'Vemos si existe la capa de etiquetas y si no la creamos
existe_capa = False
For i = 0 To ThisDrawing.Layers.Count - 1
If ThisDrawing.Layers(i).Name = "Etiqueta_elementosR" Then
existe_capa = True
Exit For
End If
Next i
If existe_capa = False Then
Set acCapa2 = ThisDrawing.Layers.Add("Etiqueta_elementosR")
With color
.ColorMethod = acColorMethodByACI
.ColorIndex = 6
End With
acCapa2.TrueColor = color
Else
Set acCapa2 = ThisDrawing.Layers("Etiqueta_elementosR")
End If
'Activamos la capa
ThisDrawing.ActiveLayer = acCapa2
'Insertamos texto con el nº de elemento
textString = elementosR(UBound(elementosR)).n
insertionPoint(0) = (varCords(0) + varCords(2) + varCords(4) + varCords(6)) / 4
insertionPoint(1) = (varCords(1) + varCords(3) + varCords(5) + varCords(7)) / 4
insertionPoint(2) = 0
Set textObj = ThisDrawing.ModelSpace. _
AddText(textString, insertionPoint, 0.01)
End If
Next cont1
'Una vez agregados los nodos y los elementosR, agregamos cargas y apoyos
ReDim cargas(0)
Dim AttList As Variant
For cont1 = 1 To ss.Count
Set objEnt = ss.Item(cont1 - 1)
'Si la capa es de apoyos
If objEnt.Layer = "Apoyos" Then
If objEnt.ObjectName = "AcDbBlockReference" Then
aux = objEnt.insertionPoint
nodo_aux = N_nudo(aux(0), aux(1))
If objEnt.EffectiveName = "Apoyo_X" Then
restricciones(0).nodos = restricciones(1).nodos & "," & long_cadena(nodo_aux, (2 + Len(nodo_aux)))
ElseIf objEnt.EffectiveName = "Apoyo_Y" Then
restricciones(1).nodos = restricciones(1).nodos & "," & long_cadena(nodo_aux, (2 + Len(nodo_aux)))
End If
End If
End If
'Si la capa es de cargas
If objEnt.Layer = "Cargas" Then
If objEnt.ObjectName = "AcDbBlockReference" Then
aux = objEnt.insertionPoint
nodo_aux = N_nudo(aux(0), aux(1))
If (objEnt.EffectiveName = "Carga") And (objEnt.HasAttributes) Then
AttList = objEnt.GetAttributes
If cargas(UBound(cargas)).nodo = "" Then 'Es la primera carga añadida
cargas(0).nodo = nodo_aux
cargas(0).valor_X = AttList(0).textString * Sin(objEnt.Rotation) * (-1)
cargas(0).valor_Y = AttList(0).textString * Cos(objEnt.Rotation)
Else 'No es la primera carga añadida
ReDim Preserve cargas(UBound(cargas) + 1)
cargas(UBound(cargas)).nodo = nodo_aux
cargas(UBound(cargas)).valor_X = AttList(0).textString * Sin(objEnt.Rotation) * (-1)
cargas(UBound(cargas)).valor_Y = AttList(0).textString * Cos(objEnt.Rotation)
End If
End If
End If
End If
Next cont1
restricciones(0).nodos = Right(restricciones(0).nodos, Len(restricciones(0).nodos) - 1)
restricciones(1).nodos = Right(restricciones(1).nodos, Len(restricciones(1).nodos) - 1)
'Ya hemos terminado con el selection set
ThisDrawing.SelectionSets.Item(nombre).Delete
Set acCapa = ThisDrawing.Layers("0")
ThisDrawing.ActiveLayer = acCapa
'Procedemos a escribir el INP
Dim FSO As FileSystemObject
Dim FSOFile As TextStream
Dim FilePath As String
FilePath = TextBox1.Text
Set FSO = New FileSystemObject
Set FSOFile = FSO.OpenTextFile(FilePath, 2, True)
FSOFile.WriteLine ("*Heading")
FSOFile.WriteLine ("** Job name: Job-1 Model name: Model-1")
FSOFile.WriteLine ("** Generated by: Rafa for Abaqus/CAE 6.11-3")
FSOFile.WriteLine ("*Preprint, echo=NO, model=NO, history=NO, contact=NO")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** PARTS")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Part, name=Part-1")
FSOFile.WriteLine ("*Node")
For i = 0 To UBound(nodos)
FSOFile.WriteLine (Linea_nodo_INP(nodos(i)))
Next i
FSOFile.WriteLine ("*Element, type=CPS4")
For i = 0 To UBound(elementosR)
FSOFile.WriteLine (Linea_elemento_rec_INP(elementosR(i)))
Next i
FSOFile.WriteLine ("*Nset, nset=_PickedSet2, internal, generate")
FSOFile.WriteLine ("
1," & long_cadena(nodos(UBound(nodos)).n, 5) & ",
1")
FSOFile.WriteLine ("*Elset, elset=_PickedSet2, internal, generate")
FSOFile.WriteLine ("
1," & long_cadena(elementosR(UBound(elementosR)).n, 5) & ",
1")
FSOFile.WriteLine ("** Section: Section-1")
FSOFile.WriteLine ("*Solid Section, elset=_PickedSet2, material=Material-1")
FSOFile.WriteLine (Espesor.Text & ",")
FSOFile.WriteLine ("*End Part")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** ASSEMBLY")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Assembly, name=Assembly")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Instance, name=Part-1-1, part=Part-1")
FSOFile.WriteLine ("*End Instance")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Nset, nset=_PickedSet4, internal, instance=Part-1-1")
FSOFile.WriteLine (restricciones(0).nodos) ' Estos son los nodos donde las condiciones de contorno son X=0
FSOFile.WriteLine ("*Nset, nset=_PickedSet5, internal, instance=Part-1-1")
FSOFile.WriteLine (restricciones(1).nodos) ' Estos son los nodos donde las condiciones de contorno son Y=0
For i = 0 To UBound(cargas)
FSOFile.WriteLine ("*Nset, nset=_PickedSet" & CStr(i + 6) & ", internal, instance=Part-1-1")
FSOFile.WriteLine (long_cadena(cargas(i).nodo, (2 + Len(cargas(i).nodo))) & ",") ' Estos son los nodos donde
existen las mismas cargas
Next i
FSOFile.WriteLine ("*End Assembly")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** MATERIALS")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Material, name=Material-1")
FSOFile.WriteLine ("*Density")
FSOFile.WriteLine (" 1e-09,") 'La densidad del material la supondremos siempre irrelevante para el calculo
FSOFile.WriteLine ("*Elastic")
FSOFile.WriteLine (Replace(Young.Text, ",", ".") & ", " & Replace(Poisson.Text, ",", ".")) 'Modulo de Young y
coeficiente de Poisson
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** BOUNDARY CONDITIONS")
FSOFile.WriteLine ("** ")
FSOFile.WriteLine ("** Name: BC-1 Type: Displacement/Rotation")
FSOFile.WriteLine ("*Boundary")
FSOFile.WriteLine ("_PickedSet4, 1, 1")
FSOFile.WriteLine ("** ")
FSOFile.WriteLine ("** Name: BC-2 Type: Displacement/Rotation")
FSOFile.WriteLine ("*Boundary")
FSOFile.WriteLine ("_PickedSet5, 2, 2")
FSOFile.WriteLine ("** ----------------------------------------------------------------")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** STEP: Step-1")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Step, name=Step-1")
FSOFile.WriteLine ("*Static")
FSOFile.WriteLine ("1., 1., 1e-05, 1.")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** LOADS")
FSOFile.WriteLine ("**")
Dim val_carga As String
For i = 0 To UBound(cargas)
If Abs(cargas(i).valor_X) > 0.05 Then
val_carga = CStr(cargas(i).valor_X)
If InStr(1, val_carga, ",") = 0 Then
val_carga = val_carga & ","
End If
FSOFile.WriteLine ("** Name: Load-" & CStr(i + 1) & "
Type: Concentrated force")
FSOFile.WriteLine ("*Cload")
FSOFile.WriteLine ("_PickedSet" & CStr(i + 6) & ", 1, " & Replace(val_carga, ",", "."))
End If
If Abs(cargas(i).valor_Y) > 0.05 Then
val_carga = CStr(cargas(i).valor_Y)
If InStr(1, val_carga, ",") = 0 Then
val_carga = val_carga & ","
End If
FSOFile.WriteLine ("** Name: Load-" & CStr(i + 1) & "
Type: Concentrated force")
FSOFile.WriteLine ("*Cload")
FSOFile.WriteLine ("_PickedSet" & CStr(i + 6) & ", 2, " & Replace(val_carga, ",", "."))
End If
Next i
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** OUTPUT REQUESTS")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Restart, write, frequency=0")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** FIELD OUTPUT: F-Output-1")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Output, field, variable=PRESELECT")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** HISTORY OUTPUT: H-Output-1")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Output, history, variable=PRESELECT")
FSOFile.WriteLine ("*End Step")
FSOFile.Close
MsgBox ("Archivo INP exportado")
End Sub
Private Sub Triangulares()
UserForm1.Hide
Dim cont As Integer
For cont = 0 To ThisDrawing.Layers.Count - 1
ThisDrawing.Layers(cont).LayerOn = True
Next cont
Dim ss As AcadSelectionSet
Dim nombre As String
'nombre = "zz"
nombre = Chr(Int(Rnd * 26) + 65) & Chr(Int(Rnd * 26) + 65)
For cont = 0 To ThisDrawing.SelectionSets.Count - 1
If ThisDrawing.SelectionSets(cont).Name = nombre Then
ThisDrawing.SelectionSets(cont).Delete
End If
Next
Set ss = ThisDrawing.SelectionSets.Add(nombre)
ss.SelectOnScreen
Dim cont1, cont2 As Integer
Dim n_vertices As Integer
Dim objEnt As AcadEntity
Dim varCords As Variant
Dim aux As Variant
Dim n_elemento As Integer
n_elemento = 0
Dim n_restriccion As Integer
n_restriccion = 0
Dim n_carga As Integer
n_carga = 0
Dim varAtributos As Variant
Dim distancia As Single
Dim angulo As Double
Dim carga As String
Dim max_n_nodos As Integer
Dim ucsObj As AcadUCS
Dim textObj As AcadText
Dim textString As String
Dim insertionPoint(0 To 2) As Double
Dim restricciones(0 To 1) As restriccion
Dim cargas() As carga
max_n_nodos = 0
ReDim nodos(0)
ReDim elementos(0)
Dim objetos_explotados As Variant
Dim nodo_aux As String
Dim area_aux As Double
For cont1 = 1 To ss.Count
Set objEnt = ss.Item(cont1 - 1)
'Si la capa es de elementos
If objEnt.Layer = "Elementos" Or objEnt.Layer = "elementos" Then
If (objEnt.ObjectName = "AcDb3dPolyline") Or (objEnt.ObjectName = "IAcad3DPolyline") Then 'Tienen
coordenadas de altura
varCords = objEnt.Coordinates
ElseIf (objEnt.ObjectName = "AcDbPolyline") Or (objEnt.ObjectName = "IAcadLWPolyline") Then
varCords = objEnt.Coordinates
ElseIf (objEnt.ObjectName = "AcDbLine") Or (objEnt.ObjectName = "IAcadLine") Then
ReDim varCords(5)
aux = objEnt.StartPoint
varCords(0) = aux(0)
varCords(1) = aux(1)
varCords(2) = aux(2)
aux = objEnt.EndPoint
varCords(3) = aux(0)
varCords(4) = aux(1)
varCords(5) = aux(2)
End If
Dim encontrado As Boolean
Dim existe_capa As Boolean
Dim acCapa As AcadLayer
Dim acCapa2 As AcadLayer
Dim color As AcadAcCmColor
Dim i As Integer
'Añadimos los nodos
For cont2 = 0 To UBound(varCords)
If (cont2 Mod 2) = 0 Then
If nodos(0).n = "" Then 'Es el primer nodo añadido
nodos(0).n = CStr(UBound(nodos)) + 1
nodos(0).x = varCords(cont2)
nodos(0).y = varCords(cont2 + 1)
'nodos(0).Z = varCords(cont2 + 2)
'Vemos si existe la capa de etiquetas y si no la creamos
existe_capa = False
For i = 0 To ThisDrawing.Layers.Count - 1
If ThisDrawing.Layers(i).Name = "Etiqueta_nodos" Then
existe_capa = True
Exit For
End If
Next i
If existe_capa = False Then
Set acCapa = ThisDrawing.Layers.Add("Etiqueta_nodos")
Set color = New AcadAcCmColor
With color
.ColorMethod = acColorMethodByACI
.ColorIndex = 3
End With
acCapa.TrueColor = color
Else
Set acCapa = ThisDrawing.Layers("Etiqueta_nodos")
End If
'Activamos la capa
ThisDrawing.ActiveLayer = acCapa
'Insertamos texto con el nº de elemento
textString = nodos(0).n
insertionPoint(0) = nodos(0).x
insertionPoint(1) = nodos(0).y
insertionPoint(2) = 0
Set textObj = ThisDrawing.ModelSpace. _
AddText(textString, insertionPoint, 0.01)
Else 'No es el primer nodo, por lo que lo deberemos buscar entre los existentes y añadirlo si no
existe
encontrado = False
For cont = 0 To UBound(nodos)
If (Abs(varCords(cont2) - nodos(cont).x) < 0.00001) And (Abs(varCords(cont2 + 1) nodos(cont).y) < 0.00001) Then
encontrado = True
Exit For
End If
Next cont
If encontrado = False Then
ReDim Preserve nodos(UBound(nodos) + 1)
nodos(UBound(nodos)).n = UBound(nodos) + 1
nodos(UBound(nodos)).x = varCords(cont2)
nodos(UBound(nodos)).y = varCords(cont2 + 1)
'nodos(UBound(nodos)).Z = varCords(cont2 + 2)
'Activamos la capa
ThisDrawing.ActiveLayer = acCapa
'Insertamos texto con el nº de elemento
textString = nodos(UBound(nodos)).n
insertionPoint(0) = nodos(UBound(nodos)).x
insertionPoint(1) = nodos(UBound(nodos)).y
insertionPoint(2) = 0
Set textObj = ThisDrawing.ModelSpace. _
AddText(textString, insertionPoint, 0.01)
End If
End If
End If
Next cont2
'Añadimos los elementos
If elementos(0).n = "" Then 'Es el primer elemento añadido
ReDim elementos(0)
Else 'No es el primer elemento
ReDim Preserve elementos(UBound(elementos) + 1)
End If
elementos(UBound(elementos)).n = CStr(UBound(elementos)) + 1
elementos(UBound(elementos)).nudos(0) = N_nudo(varCords(0), varCords(1))
elementos(UBound(elementos)).nudos(1) = N_nudo(varCords(2), varCords(3))
elementos(UBound(elementos)).nudos(2) = N_nudo(varCords(4), varCords(5))
'Debemos de comprobar que las normales son las correctas, los vertices deben estar
'situados en sentido antihorario, para ello calcularemos el area del triangulo
'Si el area es negativa, cambiaremos el nudo 0 por el 2.
area_aux = Area_tri(varCords(0), varCords(1), varCords(2), varCords(3), varCords(4), varCords(5))
If area_aux < 0 Then
elementos(UBound(elementos)).nudos(2) = N_nudo(varCords(0), varCords(1))
elementos(UBound(elementos)).nudos(1) = N_nudo(varCords(2), varCords(3))
elementos(UBound(elementos)).nudos(0) = N_nudo(varCords(4), varCords(5))
End If
'Vemos si existe la capa de etiquetas y si no la creamos
existe_capa = False
For i = 0 To ThisDrawing.Layers.Count - 1
If ThisDrawing.Layers(i).Name = "Etiqueta_elementos" Then
existe_capa = True
Exit For
End If
Next i
If existe_capa = False Then
Set acCapa2 = ThisDrawing.Layers.Add("Etiqueta_elementos")
With color
.ColorMethod = acColorMethodByACI
.ColorIndex = 6
End With
acCapa2.TrueColor = color
Else
Set acCapa2 = ThisDrawing.Layers("Etiqueta_elementos")
End If
'Activamos la capa
ThisDrawing.ActiveLayer = acCapa2
'Insertamos texto con el nº de elemento
textString = elementos(UBound(elementos)).n
insertionPoint(0) = (varCords(0) + varCords(2) + varCords(4)) / 3
insertionPoint(1) = (varCords(1) + varCords(3) + varCords(5)) / 3
insertionPoint(2) = 0
Set textObj = ThisDrawing.ModelSpace. _
AddText(textString, insertionPoint, 0.01)
End If
Next cont1
'Una vez agregados los nodos y los elementos, agregamos cargas y apoyos
ReDim cargas(0)
Dim AttList As Variant
For cont1 = 1 To ss.Count
Set objEnt = ss.Item(cont1 - 1)
'Si la capa es de apoyos
If objEnt.Layer = "Apoyos" Then
If objEnt.ObjectName = "AcDbBlockReference" Then
aux = objEnt.insertionPoint
nodo_aux = N_nudo(aux(0), aux(1))
If objEnt.EffectiveName = "Apoyo_X" Then
restricciones(0).nodos = restricciones(1).nodos & "," & long_cadena(nodo_aux, (2 + Len(nodo_aux)))
ElseIf objEnt.EffectiveName = "Apoyo_Y" Then
restricciones(1).nodos = restricciones(1).nodos & "," & long_cadena(nodo_aux, (2 + Len(nodo_aux)))
End If
End If
End If
'Si la capa es de cargas
If objEnt.Layer = "Cargas" Then
If objEnt.ObjectName = "AcDbBlockReference" Then
aux = objEnt.insertionPoint
nodo_aux = N_nudo(aux(0), aux(1))
If (objEnt.EffectiveName = "Carga") And (objEnt.HasAttributes) Then
AttList = objEnt.GetAttributes
If cargas(UBound(cargas)).nodo = "" Then 'Es la primera carga añadida
cargas(0).nodo = nodo_aux
cargas(0).valor_X = AttList(0).textString * Sin(objEnt.Rotation) * (-1)
cargas(0).valor_Y = AttList(0).textString * Cos(objEnt.Rotation)
Else 'No es la primera carga añadida
ReDim Preserve cargas(UBound(cargas) + 1)
cargas(UBound(cargas)).nodo = nodo_aux
cargas(UBound(cargas)).valor_X = AttList(0).textString * Sin(objEnt.Rotation) * (-1)
cargas(UBound(cargas)).valor_Y = AttList(0).textString * Cos(objEnt.Rotation)
End If
End If
End If
End If
Next cont1
restricciones(0).nodos = Right(restricciones(0).nodos, Len(restricciones(0).nodos) - 1)
restricciones(1).nodos = Right(restricciones(1).nodos, Len(restricciones(1).nodos) - 1)
'Ya hemos terminado con el selection set
ThisDrawing.SelectionSets.Item(nombre).Delete
Set acCapa = ThisDrawing.Layers("0")
ThisDrawing.ActiveLayer = acCapa
'Procedemos a escribir el INP
Dim FSO As FileSystemObject
Dim FSOFile As TextStream
Dim FilePath As String
FilePath = TextBox1.Text
Set FSO = New FileSystemObject
Set FSOFile = FSO.OpenTextFile(FilePath, 2, True)
FSOFile.WriteLine ("*Heading")
FSOFile.WriteLine ("** Job name: Job-1 Model name: Model-1")
FSOFile.WriteLine ("** Generated by: Rafa for Abaqus/CAE 6.11-3")
FSOFile.WriteLine ("*Preprint, echo=NO, model=NO, history=NO, contact=NO")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** PARTS")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Part, name=Part-1")
FSOFile.WriteLine ("*Node")
For i = 0 To UBound(nodos)
FSOFile.WriteLine (Linea_nodo_INP(nodos(i)))
Next i
FSOFile.WriteLine ("*Element, type=CPS3")
For i = 0 To UBound(elementos)
FSOFile.WriteLine (Linea_elemento_tri_INP(elementos(i)))
Next i
FSOFile.WriteLine ("*Nset, nset=_PickedSet2, internal, generate")
FSOFile.WriteLine ("
1," & long_cadena(nodos(UBound(nodos)).n, 5) & ",
1")
FSOFile.WriteLine ("*Elset, elset=_PickedSet2, internal, generate")
FSOFile.WriteLine ("
1," & long_cadena(elementos(UBound(elementos)).n, 5) & ",
FSOFile.WriteLine ("** Section: Section-1")
FSOFile.WriteLine ("*Solid Section, elset=_PickedSet2, material=Material-1")
FSOFile.WriteLine (Espesor.Text & ",")
FSOFile.WriteLine ("*End Part")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** ASSEMBLY")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Assembly, name=Assembly")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Instance, name=Part-1-1, part=Part-1")
1")
FSOFile.WriteLine ("*End Instance")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Nset, nset=_PickedSet4, internal, instance=Part-1-1")
FSOFile.WriteLine (restricciones(0).nodos) ' Estos son los nodos donde las condiciones de contorno son X=0
FSOFile.WriteLine ("*Nset, nset=_PickedSet5, internal, instance=Part-1-1")
FSOFile.WriteLine (restricciones(1).nodos) ' Estos son los nodos donde las condiciones de contorno son Y=0
For i = 0 To UBound(cargas)
FSOFile.WriteLine ("*Nset, nset=_PickedSet" & CStr(i + 6) & ", internal, instance=Part-1-1")
FSOFile.WriteLine (long_cadena(cargas(i).nodo, (2 + Len(cargas(i).nodo))) & ",") ' Estos son los nodos donde
existen las mismas cargas
Next i
FSOFile.WriteLine ("*End Assembly")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** MATERIALS")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Material, name=Material-1")
FSOFile.WriteLine ("*Density")
FSOFile.WriteLine (" 1e-09,") 'La densidad del material la supondremos siempre irrelevante para el calculo
FSOFile.WriteLine ("*Elastic")
FSOFile.WriteLine (Replace(Young.Text, ",", ".") & ", " & Replace(Poisson.Text, ",", ".")) 'Modulo de Young y
coeficiente de Poisson
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** BOUNDARY CONDITIONS")
FSOFile.WriteLine ("** ")
FSOFile.WriteLine ("** Name: BC-1 Type: Displacement/Rotation")
FSOFile.WriteLine ("*Boundary")
FSOFile.WriteLine ("_PickedSet4, 1, 1")
FSOFile.WriteLine ("** ")
FSOFile.WriteLine ("** Name: BC-2 Type: Displacement/Rotation")
FSOFile.WriteLine ("*Boundary")
FSOFile.WriteLine ("_PickedSet5, 2, 2")
FSOFile.WriteLine ("** ----------------------------------------------------------------")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** STEP: Step-1")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Step, name=Step-1")
FSOFile.WriteLine ("*Static")
FSOFile.WriteLine ("1., 1., 1e-05, 1.")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** LOADS")
FSOFile.WriteLine ("**")
Dim val_carga As String
For i = 0 To UBound(cargas)
If Abs(cargas(i).valor_X) > 0.05 Then
val_carga = CStr(cargas(i).valor_X)
If InStr(1, val_carga, ",") = 0 Then
val_carga = val_carga & ","
End If
FSOFile.WriteLine ("** Name: Load-" & CStr(i + 1) & "
Type: Concentrated force")
FSOFile.WriteLine ("*Cload")
FSOFile.WriteLine ("_PickedSet" & CStr(i + 6) & ", 1, " & Replace(val_carga, ",", "."))
End If
If Abs(cargas(i).valor_Y) > 0.05 Then
val_carga = CStr(cargas(i).valor_Y)
If InStr(1, val_carga, ",") = 0 Then
val_carga = val_carga & ","
End If
FSOFile.WriteLine ("** Name: Load-" & CStr(i + 1) & "
Type: Concentrated force")
FSOFile.WriteLine ("*Cload")
FSOFile.WriteLine ("_PickedSet" & CStr(i + 6) & ", 2, " & Replace(val_carga, ",", "."))
End If
Next i
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** OUTPUT REQUESTS")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Restart, write, frequency=0")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** FIELD OUTPUT: F-Output-1")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Output, field, variable=PRESELECT")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("** HISTORY OUTPUT: H-Output-1")
FSOFile.WriteLine ("**")
FSOFile.WriteLine ("*Output, history, variable=PRESELECT")
FSOFile.WriteLine ("*End Step")
FSOFile.Close
MsgBox ("Archivo INP exportado")
End Sub
Private Function Linea_elemento_rec_INP(elemen
Dim n As String
Dim nudo1 As String
Dim nudo2 As String
Dim nudo3 As String
Dim nudo4 As String
n = long_cadena(elemen.n, 3)
nudo1 = long_cadena(CStr(elemen.nudos(0)),
nudo2 = long_cadena(CStr(elemen.nudos(1)),
nudo3 = long_cadena(CStr(elemen.nudos(2)),
nudo4 = long_cadena(CStr(elemen.nudos(3)),
Linea_elemento_rec_INP = n & "," & nudo4 &
haya problemas con las normales
End Function
As elementoR) As String
4)
4)
4)
4)
"," & nudo3 & "," & nudo2 & "," & nudo1 'En orden contrario para que no
Private Function Linea_elemento_tri_INP(elemen
Dim n As String
Dim nudo1 As String
Dim nudo2 As String
Dim nudo3 As String
n = long_cadena(elemen.n, 3)
nudo1 = long_cadena(CStr(elemen.nudos(0)),
nudo2 = long_cadena(CStr(elemen.nudos(1)),
nudo3 = long_cadena(CStr(elemen.nudos(2)),
Linea_elemento_tri_INP = n & "," & nudo1 &
End Function
Private
Dim
Dim
Dim
As elemento) As String
4)
4)
4)
"," & nudo2 & "," & nudo3
Function Linea_nodo_INP(nodo As Nudo) As String
n As String
x As String
y As String
n = nodo.n
x = Format(nodo.x, "#0.0000000000000")
y = Format(nodo.y, "#0.0000000000000")
x = Replace(x, ",", ".")
y = Replace(y, ",", ".")
If InStr(1, x, ".") = 0 Then
x = x & "."
End If
If InStr(1, y, ".") = 0 Then
y = y & "."
End If
n = long_cadena(n, 7)
x = long_cadena(x, 13)
y = long_cadena(y, 13)
Linea_nodo_INP = n & "," & x & "," & y
End Function
Public Function N_nudo(ByVal x As Double, ByVal y As Double) As String
Dim cont As Integer
For cont = 0 To UBound(nodos)
If (Abs(x - nodos(cont).x) < 0.00001) And (Abs(y - nodos(cont).y) < 0.00001) Then
N_nudo = nodos(cont).n
Exit For
End If
Next cont
End Function
Option Explicit
Public Type Carga
n As Integer
nodo As Integer
sentido As String
valor As Double
End Type
Public Type Elemento
n As Integer
nodo1 As Integer
nodo2 As Integer
nodo3 As Integer
End Type
Public Type Apoyo
nodo As String
X As String
Y As String
End Type
Private Function lee_INP()
Dim myFile As String, text As String, textline As String, posLat As Integer, posLong As Integer
Dim Definicion_nodos As Boolean
Dim Definicion_elementos As Boolean
Dim Definicion_espesor As Boolean
Dim Definicion_material As Boolean
Dim Definicion_grupo As Boolean
Dim Definicion_apoyo As Boolean
Dim Definicion_carga As Boolean
Dim i As Integer
Dim grupos() As String
ReDim grupos(0)
Dim apoyos() As Apoyo
ReDim apoyos(0)
Dim cargas() As Carga
ReDim cargas(0)
Definicion_nodos = False
Definicion_elementos = False
Definicion_espesor = False
Definicion_material = False
Definicion_grupo = False
Definicion_apoyo = False
Definicion_carga = False
Dim n_nodos As Integer
Dim n_elementos As Integer
n_nodos = 0
n_elementos = 0
'Borramos todos los datos existentes
Range("A3:Y65590").Select
Selection.Delete
Dim STR As String
Dim V As Variant
myFile = Application.GetOpenFilename()
'Movemos los botones
Application.Sheets("Datos generales").Activate
Columns("A:E").Select
Dim dist_a_izda As Double
dist_a_izda = Selection.Width
Mueve_botones (dist_a_izda)
Dim j As Integer
Dim encontrado As Boolean
encontrado = False
Open myFile For Input As #1
Do Until EOF(1)
Line Input #1, textline
text = textline
If (Definicion_nodos = True) And (IsNumeric(Trim(Left(text, 7)))) Then 'Esta linea define un nodo
n_nodos = n_nodos + 1
Range(rango(n_nodos + 2, 1)) = Trim(Left(text, 7)) 'Nº de nodo
STR = Right(text, 27) ' Aquí tomo todo lo que hay a la derecha de la primera coma
STR = Trim(Left(STR, 13)) ' Aquí tomo todo lo que hay a la izquierda de la segunda coma
'STR = Replace(STR, ".", ",")
Range(rango(n_nodos + 2, 2)) = Val(STR) 'Coordenada X del nodo
STR = Trim(Right(text, 13))
'STR = Replace(STR, ".", ",")
Range(rango(n_nodos + 2, 3)) = Val(STR) 'Coordenada Y del nodo
Else
Definicion_nodos = False
End If
If (Definicion_elementos = True) And (IsNumeric(Trim(Left(text, 3)))) Then 'Esta linea define un elemento
n_elementos = n_elementos + 1
Range(rango(n_elementos + 2, 5)) = Trim(Left(text, 3)) 'Nº de elemento
STR = Right(text, Len(text) - 4) ' Aquí tomo todo lo que hay a la derecha de la primera coma
Range(rango(n_elementos + 2, 6)) = Trim(Left(STR, 4)) 'Nodo 1
STR = Right(STR, 9) ' Aquí tomo todo lo que hay a la derecha de la primera coma
Range(rango(n_elementos + 2, 7)) = Trim(Left(STR, 4)) 'Nodo 2
STR = Right(STR, 4) ' Aquí tomo todo lo que hay a la derecha de la primera coma
Range(rango(n_elementos + 2, 8)) = Trim(STR) 'Nodo 3
Else
Definicion_elementos = False
End If
If (Definicion_espesor = True) And (IsNumeric(Val(text))) Then 'Esta linea define el espesor
For i = 1 To n_elementos
Range(rango(i + 2, 9)) = Trim(Left(text, (Len(text) - 1))) 'Espesor del elemento
Range(rango(i + 2, 10)) = "1" 'Material del elemento"
Next i
Definicion_espesor = False
End If
If (Definicion_material = True) And (IsNumeric(Trim(Left(text, 1)))) Then 'Esta linea define el material
Range(rango(3, 12)) = "1" 'Nº de Material "
Range(rango(3, 13)) = Trim(Left(text, (InStr(1, text, ",") - 1))) 'Módulo de Young
Range(rango(3, 14)) = Trim(Right(text, (Len(text) - InStr(1, text, ",")))) 'Módulo de Poisson
Else
Definicion_material = False
End If
If (Definicion_grupo = True) And (IsNumeric(Trim(Left(text, 5)))) Then 'Esta linea define un grupo
If Right(text, 1) = "," Then
grupos(UBound(grupos)) = Left(text, Len(text) - 1)
Else
grupos(UBound(grupos)) = text
End If
Else
Definicion_grupo = False
End If
If (Definicion_apoyo = True) And ((Trim(Left(text, 10))) = "_PickedSet") Then 'Esta linea define un apoyo
STR = Left(text, InStr(text, ",") - 1)
STR = Right(STR, Len(STR) - 10)
V = Split(grupos(STR), ",")
STR = Right(text, 1)
For i = 1 To UBound(V) + 1
If apoyos(UBound(apoyos)).nodo = "" Then 'Es el primer apoyo definido
apoyos(UBound(apoyos)).nodo = Trim(CStr(V(i - 1)))
If STR = 1 Then
apoyos(UBound(apoyos)).X = 0
ElseIf STR = 2 Then
apoyos(UBound(apoyos)).Y = 0
End If
Else 'No es el primer apoyo definido
'Comprueba que este nodo no existe en las condiciones de contorno
For j = 0 To UBound(apoyos)
If apoyos(j).nodo = Trim(CStr(V(i - 1))) Then
encontrado = True
If STR = 1 Then
apoyos(j).X = 0
ElseIf STR = 2 Then
apoyos(j).Y = 0
End If
Exit For
End If
Next j
If encontrado = False Then
ReDim Preserve apoyos(UBound(apoyos) + 1)
apoyos(UBound(apoyos)).nodo = Trim(CStr(V(i - 1)))
If STR = 1 Then
apoyos(UBound(apoyos)).X = 0
ElseIf STR = 2 Then
apoyos(UBound(apoyos)).Y = 0
End If
End If
End If
Next i
Else
Definicion_apoyo = False
End If
If (Definicion_carga = True) And ((Trim(Left(text, 10))) = "_PickedSet") Then 'Esta linea define una carga
STR = Left(text, InStr(text, ",") - 1)
STR = Right(STR, Len(STR) - 10)
V = Split(grupos(STR), ",")
STR = Trim(Right(text, Len(text) - 12))
For i = 1 To UBound(V) + 1
If cargas(UBound(cargas)).n = 0 Then 'Es el primer apoyo definido
Else 'No es el primer apoyo definido
ReDim Preserve cargas(UBound(cargas) + 1)
End If
cargas(UBound(cargas)).n = i
cargas(UBound(cargas)).nodo = CInt(Trim(CStr(V(i - 1))))
If Left(STR, 1) = "1" Then
cargas(UBound(cargas)).sentido = "X"
ElseIf Left(STR, 1) = "2" Then
cargas(UBound(cargas)).sentido = "Y"
End If
cargas(UBound(cargas)).valor = CDbl(Trim(Right(STR, Len(STR) - 2)))
Next i
End If
If text = "*Node" Then 'Empieza la definicion de nodos
Definicion_nodos = True
End If
If Left(text, 9) = "*Element," Then 'Empieza la definicion de elementos
Definicion_nodos = False
Definicion_elementos = True
End If
If Left(text, 14) = "*Solid Section" Then 'Empieza la definicion del espesor
Definicion_nodos = False
Definicion_elementos = False
Definicion_espesor = True
End If
If Left(text, 8) = "*Elastic" Then 'Empieza la definicion del material
Definicion_nodos = False
Definicion_elementos = False
Definicion_espesor = False
Definicion_material = True
End If
If Left(text, 22) = "*Nset, nset=_PickedSet" Then 'Empieza la definicion de un grupo
Definicion_nodos = False
Definicion_elementos = False
Definicion_espesor = False
Definicion_material = False
Definicion_grupo = True
STR = Left(text, (InStr(1, text, ", internal") - 1))
STR = Right(STR, Len(STR) - 22)
ReDim Preserve grupos(Val(STR))
End If
If Left(text, 9) = "*Boundary" Then 'Empieza la definicion de un apoyo
Definicion_nodos = False
Definicion_elementos = False
Definicion_espesor = False
Definicion_material = False
Definicion_grupo = False
Definicion_apoyo = True
End If
If Left(text, 8) = "** LOADS" Then 'Empieza la definicion de cargas
Definicion_nodos = False
Definicion_elementos = False
Definicion_espesor = False
Definicion_material = False
Definicion_grupo = False
Definicion_apoyo = False
Definicion_carga = True
End If
Loop
Close #1
For i = 0 To UBound(apoyos)
Range(rango(i + 3, 16)).Value = CStr(i + 1)
Range(rango(i + 3, 17)).Value = CStr(apoyos(i).nodo)
If apoyos(i).X = ""
Range(rango(i +
Else
Range(rango(i +
End If
If apoyos(i).Y = ""
Range(rango(i +
Else
Range(rango(i +
End If
Next i
Then
3, 18)).Value = "???"
3, 18)).Value = CStr(apoyos(i).X)
Then
3, 19)).Value = "???"
3, 19)).Value = CStr(apoyos(i).Y)
For i = 0 To UBound(cargas)
Range(rango(i + 3, 21)).Value
Range(rango(i + 3, 22)).Value
Range(rango(i + 3, 23)).Value
Range(rango(i + 3, 24)).Value
Next i
=
=
=
=
CStr(cargas(i).n)
CStr(cargas(i).nodo)
CStr(cargas(i).sentido)
CStr(cargas(i).valor)
End Function
Private Function ensambla_k_reducida()
Application.Sheets("Datos generales").Activate
Dim n_apoyos As Integer
n_apoyos = Range("S1").Value
Dim n_cargas As Integer
n_cargas = Range("W1").Value
'Copiamos la matriz de rigidez completa
Worksheets("Matriz global de rigidez").Copy After:=Sheets(Sheets.Count)
Dim hoja As Worksheet
Set hoja = ActiveWorkbook.Sheets("Matriz global de rigidez (2)")
'La movemos al final
hoja.Activate
ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
Application.ScreenUpdating = True
'Le damos nombre
hoja.Name = "Matriz rigidez reducida"
'Copiamos todas las celdas escritas, y pegamos en el mismo area valores y formatos
Dim i As Integer
Dim j As Integer
''''
i = 1
''''
Do While i > 0
''''
If Range(rango(1, i)).Value = "Fuerzas" Then
''''
Exit Do
''''
End If
''''
i = i + 1
''''
Loop
''''
Range(rango(1, 1) & ":" & rango(i, i)).Copy
''''
Range(rango(1, 1) & ":" & rango(i, i)).PasteSpecial xlPasteValues
''''
Range(rango(1, 1) & ":" & rango(i, i)).PasteSpecial xlPasteFormats
'Borramos las filas y las columnas que tengan desplazamientos y giros conocidos
Dim filas_borrar() As Integer
Dim inicio As Integer
Dim filaX As Integer
Dim filaY As Integer
Application.Sheets("Datos generales").Activate
ReDim filas_borrar(0)
For i = 1 To n_apoyos
If Range(rango((i + 2), 16)).Value <> "" Then 'Empieza definicion de apoyo
If Range(rango((i + 2), 17)).Value <> "" Then 'Define el nº de nodo
filaX = 0
filaY = 0
inicio = CInt(Range(rango((i + 2), 17)).Value) 'nº de nodo
If Range(rango((i + 2), 18)).Value = 0 Then
filaX = inicio * 2 'coordenada X
End If
If Range(rango((i + 2), 19)).Value = 0 Then
filaY = (inicio * 2) + 1 'coordenada Y
End If
If filaX <> 0 Then
If filas_borrar(UBound(filas_borrar)) <> 0 Then
ReDim Preserve filas_borrar(UBound(filas_borrar) + 1)
End If
filas_borrar(UBound(filas_borrar)) = filaX
End If
If filaY <> 0 Then
If filas_borrar(UBound(filas_borrar)) <> 0 Then
ReDim Preserve filas_borrar(UBound(filas_borrar) + 1)
End If
filas_borrar(UBound(filas_borrar)) = filaY
End If
End If
End If
Next i
Application.Sheets("Matriz rigidez reducida").Activate
'Borramos las filas y columnas especificadas en el array filas_borrar
Dim STR As String
STR = ""
For i = 0 To UBound(filas_borrar)
If i = UBound(filas_borrar) Then
STR = STR & rango(1, filas_borrar(i))
Else
STR = STR & rango(1, filas_borrar(i)) & ","
End If
Next i
Range(STR).EntireColumn.Select
Selection.EntireColumn.Delete
STR = ""
For i = 0 To UBound(filas_borrar)
If i = UBound(filas_borrar) Then
STR = STR & rango(filas_borrar(i), 1)
Else
STR = STR & rango(filas_borrar(i), 1) & ","
End If
Next i
Range(STR).EntireRow.Select
Selection.EntireRow.Delete
Range("A:A").Select
Selection.Insert Shift:=xlRight
'Resolvemos por gauss-jordan
'Gauss_jordan
'Resolvemos por k_inversa
K_inversa
End Function
Private Function K_inversa()
Application.Sheets("Matriz rigidez reducida").Activate
Dim n_filas As Integer
Dim k As String
Dim i As Integer
n_filas = Application.CountA(Range("B1:B65536"))
Dim rang As String
rang = "C" & CStr(n_filas + 4) & ":" & rango(n_filas + 3 + n_filas, n_filas + 2)
k = "=MINVERSE(R[-" & (n_filas + 2) & "]C[]:R[-3]C[" & (n_filas - 1) & "])"
Range(rang).Select
Selection.FormulaArray = k
'Una vez termina el calculo de la matriz inversa colocamos los resultados
Dim col As Integer
col = n_filas + 5
Range(rango(1, col)).Value = "Desplz"
Range(rango(1, col + 1)).Value = "Valor"
For i = 1 To n_filas
Range(rango(i + 1, col)).FormulaLocal = "=B" & i + 1
Next i
rang = rango(2, col + 1) & ":" & rango(n_filas + 1, col + 1)
k = "=MMULT(R[" & (n_filas + 2) & "]C[" & (-n_filas - 3) & "]:R[" & (2 * n_filas + 1) & "]C[" & (-4) & "],R[]C[3]:R[" & (n_filas - 1) & "]C[-3])"
Range(rang).Select
Selection.FormulaArray = k
End Function
Private Function Gauss_jordan()
Application.Sheets("Matriz rigidez reducida").Activate
Dim n_veces As Integer
Dim i As Integer
Dim k As Integer
Dim j As Integer
Dim fila As Integer
n_veces = Application.CountA(Range("B1:B65536"))
'Hay que hacer el pivotamiento n_veces
For i = 1 To n_veces
fila = ((i * (n_veces + 2)) + 1 + i)
Range(rango(fila, 3) & ":" & rango(fila, (n_veces + 3))).FormulaArray = "=" & rango((fila - n_veces - 2), 3) &
":" & rango((fila - n_veces - 2), (n_veces + 3)) & "/" & rango((fila - n_veces - 2), (i + 2))
'Rellena las filas inferiores
For k = (fila + 1) To (n_veces + fila - i)
For j = 3 To n_veces + 3
Range(rango(k, j)).FormulaLocal = "=" & rango((k - n_veces - 2), j) & "-(" & _
rango((k - n_veces - 2), (i + 2)) & "*" & rango(fila, j) & ")"
Next j
Next k
'Rellena las filas superiores
For k = (fila - i + 1) To (fila - 1) 'Cdo i=1 no entra en el bucle..ok
For j = 3 To n_veces + 3
Range(rango(k, j)).FormulaLocal = "=" & rango((k - n_veces - 2), j) & "-(" & _
rango((k - n_veces - 2), (i + 2)) & "*" & rango(fila, j) & ")"
Next j
Next k
Next i
'Una vez termina el pivotamiento resumimos los resultados
Dim col As Integer
col = n_veces + 5
Range(rango(1, col)).Value = "Desplz"
Range(rango(1, col + 1)).Value = "Valor"
For i = 1 To n_veces
Range(rango(i + 1, col)).FormulaLocal = "=B" & i + 1
Range(rango(i + 1, col + 1)).FormulaLocal = "=" & rango(k + i - n_veces, n_veces + 3)
Next i
End Function
Private Function calcula_resultados()
Application.Sheets("Datos generales").Activate
Dim n_elementos As Integer
Dim n_nodos As Integer
Dim i As Integer
n_elementos = Range("G1").Value
n_nodos = Range("C1").Value
'Genera una hoja nueva
Dim hoja As Worksheet
Set hoja = ActiveWorkbook.Sheets.Add
'La movemos al final
ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
Application.ScreenUpdating = True
'Le damos nombre
hoja.Name = "Resultados"
ActiveSheet.Cells(1, 1).Value = "Nodo"
ActiveSheet.Cells(1, 2).Value = "X_ini"
ActiveSheet.Cells(1, 3).Value = "Y_ini"
ActiveSheet.Cells(1, 4).Value = "Desp_X"
ActiveSheet.Cells(1, 5).Value = "Desp_Y"
ActiveSheet.Cells(1, 6).Value = "X_fin"
ActiveSheet.Cells(1, 7).Value = "Y_fin"
ActiveSheet.Cells(1, 8).Value = "Escala"
ActiveSheet.Cells(2, 8).Value = 1000
Range("A2:C" & n_nodos + 1).Select
Selection.FormulaArray = "='Datos generales'!A3:C" & n_nodos + 2
Dim formula_X As String
Dim formula_Y As String
Dim n_veces As Integer
n_veces = Application.CountA(Range("'Matriz rigidez reducida'!B1:B65536"))
For i = 1 To n_nodos
formula_X = "INDICE('Matriz rigidez reducida'!" & rango(2, n_veces + 5) & ":" & Split(Columns(n_veces +
6).Address(, False), ":")(1) & n_veces + 1 & ";COINCIDIR(" & Chr(34) & "u" & i & Chr(34) & ";'Matriz rigidez reducida'!"
& rango(2, n_veces + 5) & ":" & Split(Columns(n_veces + 5).Address(, False), ":")(1) & n_veces + 1 & ";0);2))"
formula_X = "=SI(ESERROR(" & formula_X & ";0;(" & formula_X & ")"
Range(rango(i + 1, 4)).FormulaLocal = formula_X
formula_Y = "INDICE('Matriz rigidez reducida'!" & rango(2, n_veces + 5) & ":" & Split(Columns(n_veces +
6).Address(, False), ":")(1) & n_veces + 1 & ";COINCIDIR(" & Chr(34) & "v" & i & Chr(34) & ";'Matriz rigidez reducida'!"
& rango(2, n_veces + 5) & ":" & Split(Columns(n_veces + 5).Address(, False), ":")(1) & n_veces + 1 & ";0);2))"
formula_Y = "=SI(ESERROR(" & formula_Y & ";0;(" & formula_Y & ")"
Range(rango(i + 1, 5)).FormulaLocal = formula_Y
Range(rango(i + 1, 6)).FormulaLocal = "=" & rango(i + 1, 2) & "+" & "$H$2*" & rango(i + 1, 4)
Range(rango(i + 1, 7)).FormulaLocal = "=" & rango(i + 1, 3) & "+" & "$H$2*" & rango(i + 1, 5)
Next i
Dim array_elementos() As Elemento
For i = 1 To n_elementos
If i = 1 Then
ReDim array_elementos(0)
Else
ReDim Preserve array_elementos(UBound(array_elementos) + 1)
End If
array_elementos(UBound(array_elementos)).n = Sheets("Datos Generales").Range("E" & i + 2).Value
array_elementos(UBound(array_elementos)).nodo1 = Sheets("Datos Generales").Range("F" & i + 2).Value
array_elementos(UBound(array_elementos)).nodo2 = Sheets("Datos Generales").Range("G" & i + 2).Value
array_elementos(UBound(array_elementos)).nodo3 = Sheets("Datos Generales").Range("H" & i + 2).Value
Next i
'
'
'Creamos un grafico de barras
Dim j As Integer
Dim chrt As ChartObject
Set chrt = ActiveSheet.ChartObjects.Add _
(Left:=100, Width:=750, Top:=130, Height:=440)
chrt.Chart.ChartType = xlXYScatterLinesNoMarkers
'Dibujamos el estado deformado
i = 1
For j = 1 To n_elementos
chrt.Chart.SeriesCollection.NewSeries
chrt.Chart.SeriesCollection(j + i - 1).XValues = "=Resultados!$F$" & (array_elementos(j - 1).nodo1 + 1) & _
",Resultados!$F$" & (array_elementos(j - 1).nodo2 + 1) & _
",Resultados!$F$" & (array_elementos(j - 1).nodo3 + 1) & _
",Resultados!$F$" & (array_elementos(j - 1).nodo1 + 1)
chrt.Chart.SeriesCollection(j + i - 1).Values = "=Resultados!$G$" & (array_elementos(j - 1).nodo1 + 1) & _
",Resultados!$G$" & (array_elementos(j - 1).nodo2 + 1) & _
",Resultados!$G$" & (array_elementos(j - 1).nodo3 + 1) & _
",Resultados!$G$" & (array_elementos(j - 1).nodo1 + 1)
chrt.Chart.Axes(xlCategory).HasMinorGridlines = False
chrt.Chart.Axes(xlValue).HasMajorGridlines = False
chrt.Chart.Axes(xlValue).HasMinorGridlines = False
chrt.Chart.HasLegend = False
chrt.Chart.SeriesCollection(j + i - 1).Format.Line.Weight = 2
chrt.Chart.SeriesCollection(j + i - 1).Border.Color = RGB(255, 0, 0)
Next j
Dim max As Double
max = CInt(Application.WorksheetFunction.max(Range("B2:G" & n_nodos + 1)))
chrt.Chart.Axes(xlCategory).HasMajorGridlines = True
chrt.Chart.Axes(xlCategory).HasMinorGridlines = True
chrt.Chart.Axes(xlValue).HasMajorGridlines = True
chrt.Chart.Axes(xlValue).HasMinorGridlines = True
chrt.Chart.Axes(xlCategory).maximumescale = max
chrt.Chart.Axes(xlValue).maximumescale = max
End Function
Private Function ensambla_matriz_completa()
Application.Sheets("Datos generales").Activate
Dim n_elementos As Integer
Dim n_nodos As Integer
Dim n_cargas As Integer
Dim i As Integer
n_elementos = Range("G1").Value
n_nodos = Range("C1").Value
n_cargas = Range("W1").Value
Dim array_cargas() As Carga
For i = 3 To n_cargas + 2
If i = 3 Then
ReDim array_cargas(0)
Else
ReDim Preserve array_cargas(UBound(array_cargas) + 1)
End If
array_cargas(UBound(array_cargas)).n = Sheets("Datos Generales").Range("U" & i).Value
array_cargas(UBound(array_cargas)).nodo = Sheets("Datos Generales").Range("V" & i).Value
array_cargas(UBound(array_cargas)).sentido = Sheets("Datos Generales").Range("W" & i).Value
array_cargas(UBound(array_cargas)).valor = Sheets("Datos Generales").Range("X" & i).Value
Next i
'Genera una hoja nueva
Dim hoja As Worksheet
Set hoja = ActiveWorkbook.Sheets.Add
'La movemos al final
ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
Application.ScreenUpdating = True
'Le damos nombre
hoja.Name = "Matriz global de rigidez"
Dim j As Integer
Dim k As Integer
For i = 1 To n_nodos
ActiveSheet.Cells((2 * i), 1).FormulaLocal = "=CONCATENAR(" & Chr(34) & "u"
CStr(i + 2) & ")"
ActiveSheet.Cells((2 * i + 1), 1).FormulaLocal = "=CONCATENAR(" & Chr(34) &
generales'!A" & CStr(i + 2) & ")"
Next i
For i = 1 To n_nodos
ActiveSheet.Cells(1, (2 * i)).FormulaLocal = "=CONCATENAR(" & Chr(34) & "u"
CStr(i + 2) & ")"
ActiveSheet.Cells(1, (2 * i + 1)).FormulaLocal = "=CONCATENAR(" & Chr(34) &
generales'!A" & CStr(i + 2) & ")"
Next i
k = 2 * i
ActiveSheet.Cells(1, k).Value = "Fuerzas"
'Ensamablamos las cargas en los nodos
For i = 2 To ((2 * n_nodos) + 1) 'filas
Range(rango(i, k)).FormulaLocal = "=0"
Next i
For j = 1 To n_cargas 'filas
i = (Sheets("Datos generales").Range(rango(j + 2, 22)).Value) * 2
If Sheets("Datos generales").Range(rango(j + 2, 23)).Value = "Y" Then
i = i + 1
& Chr(34) & ";'Datos generales'!A" &
"v" & Chr(34) & ";'Datos
& Chr(34) & ";'Datos generales'!A" &
"v" & Chr(34) & ";'Datos
End If
Sheets("Matriz global de rigidez").Select
Range(rango(i, k)).FormulaLocal = Range(rango(i, k)).FormulaLocal & "+'Datos generales'!X" & CStr(j + 2)
Next j
'Ensamablamos las rigideces de los elementos
Dim formula As String
Dim fila As Integer
Dim columna As Integer
Dim valor As Double
Dim formula1 As String
Dim cadena_elemento As String
Dim z As Integer
'Ensamblaje por numeros 2
For i = 2 To ((2 * n_nodos) + 1) 'filas
For j = 2 To ((2 * n_nodos) + 1) 'columnas
Range(rango(i, j)).Value = 0
Next j
Next i
Dim nodo1 As Integer
Dim nodo2 As Integer
Dim nodo3 As Integer
Dim rig As String
For k = 1 To n_elementos
'En la hoja de cada elemento, vemos que nodos tiene el elemento en cuestion
cadena_elemento = "Elemento" & CStr(k)
nodo1 = Sheets(cadena_elemento).Range("A3").Value
nodo2 = Sheets(cadena_elemento).Range("A4").Value
nodo3 = Sheets(cadena_elemento).Range("A5").Value
Sheets("Matriz global de rigidez").Select
'Actuamos sobre la fila x del nodo 1
fila = 2 * nodo1 - 1 + 1
'Actuamos en las 6 columnas que tocan en esta fila
'Columna 1
columna = 2 * nodo1 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("B30").Value
'Columna 2
columna = 2 * nodo1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("C30").Value
'Columna 3
columna = 2 * nodo2 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("D30").Value
'Columna 4
columna = 2 * nodo2 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("E30").Value
'Columna 5
columna = 2 * nodo3 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("F30").Value
'Columna 6
columna = 2 * nodo3 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("G30").Value
'Actuamos sobre la fila y del nodo 1
fila = 2 * nodo1 + 1
'Actuamos en las 6 columnas que tocan en esta
'Columna 1
columna = 2 * nodo1 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 2
columna = 2 * nodo1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 3
columna = 2 * nodo2 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 4
columna = 2 * nodo2 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 5
columna = 2 * nodo3 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 6
columna = 2 * nodo3 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
fila
Sheets(cadena_elemento).Range("B31").Value
Sheets(cadena_elemento).Range("C31").Value
Sheets(cadena_elemento).Range("D31").Value
Sheets(cadena_elemento).Range("E31").Value
Sheets(cadena_elemento).Range("F31").Value
Sheets(cadena_elemento).Range("G31").Value
'Actuamos sobre la fila x del nodo 2
fila = 2 * nodo2 - 1 + 1
'Actuamos en las 6 columnas que tocan en esta fila
'Columna 1
columna = 2 * nodo1 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("B32").Value
'Columna 2
columna = 2 * nodo1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 3
columna = 2 * nodo2 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 4
columna = 2 * nodo2 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 5
columna = 2 * nodo3 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 6
columna = 2 * nodo3 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
+ Sheets(cadena_elemento).Range("C32").Value
+ Sheets(cadena_elemento).Range("D32").Value
+ Sheets(cadena_elemento).Range("E32").Value
+ Sheets(cadena_elemento).Range("F32").Value
+ Sheets(cadena_elemento).Range("G32").Value
'Actuamos sobre la fila y del nodo 2
fila = 2 * nodo2 + 1
'Actuamos en las 6 columnas que tocan en esta
'Columna 1
columna = 2 * nodo1 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 2
columna = 2 * nodo1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 3
columna = 2 * nodo2 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 4
columna = 2 * nodo2 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 5
columna = 2 * nodo3 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 6
columna = 2 * nodo3 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
fila
Sheets(cadena_elemento).Range("B33").Value
Sheets(cadena_elemento).Range("C33").Value
Sheets(cadena_elemento).Range("D33").Value
Sheets(cadena_elemento).Range("E33").Value
Sheets(cadena_elemento).Range("F33").Value
Sheets(cadena_elemento).Range("G33").Value
'Actuamos sobre la fila x del nodo 3
fila = 2 * nodo3 - 1 + 1
'Actuamos en las 6 columnas que tocan en esta
'Columna 1
columna = 2 * nodo1 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 2
columna = 2 * nodo1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 3
columna = 2 * nodo2 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 4
columna = 2 * nodo2 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 5
columna = 2 * nodo3 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 6
columna = 2 * nodo3 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Actuamos sobre la fila y del nodo 3
fila = 2 * nodo3 + 1
'Actuamos en las 6 columnas que tocan en esta
'Columna 1
columna = 2 * nodo1 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 2
columna = 2 * nodo1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 3
columna = 2 * nodo2 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 4
columna = 2 * nodo2 + 1
rig = Range(rango(fila, columna)).Value
fila
Sheets(cadena_elemento).Range("B34").Value
Sheets(cadena_elemento).Range("C34").Value
Sheets(cadena_elemento).Range("D34").Value
Sheets(cadena_elemento).Range("E34").Value
Sheets(cadena_elemento).Range("F34").Value
Sheets(cadena_elemento).Range("G34").Value
fila
Sheets(cadena_elemento).Range("B35").Value
Sheets(cadena_elemento).Range("C35").Value
Sheets(cadena_elemento).Range("D35").Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("E35").Value
'Columna 5
columna = 2 * nodo3 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("F35").Value
'Columna 6
columna = 2 * nodo3 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("G35").Value
Next k
End Function
Private Function genera_hojas_elementos()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim n_elementos As Integer
Dim n_nodos As Integer
Dim n_materiales As Integer
Dim n_cargas As Integer
Dim n_apoyos As Integer
'
Range("AC1").FormulaR1C1 = Application.CountA(Range("Z1:Z65536")) - 2
'
Range("AK1").FormulaR1C1 = Application.CountA(Range("AI1:AI65536")) - 2
'
Range("N1").FormulaR1C1 = Application.CountA(Range("L1:L65536")) - 2
'
Range("H1").FormulaR1C1 = Application.CountA(Range("F1:F65536")) - 2
'
Range("C1").FormulaR1C1 = Application.CountA(Range("A1:A65536")) - 2
'
Range("T1").FormulaR1C1 = Application.CountA(Range("R1:R65536")) - 2
n_materiales = Range("N1").Value
n_elementos = Range("G1").Value
n_nodos = Range("C1").Value
n_cargas = Range("W1").Value
Dim array_cargas() As Carga
For i = 3 To n_cargas + 2
If i = 3 Then
ReDim array_cargas(0)
Else
ReDim Preserve array_cargas(UBound(array_cargas) + 1)
End If
array_cargas(UBound(array_cargas)).n = Sheets("Datos Generales").Range("U" & i).Value
array_cargas(UBound(array_cargas)).nodo = Sheets("Datos Generales").Range("V" & i).Value
array_cargas(UBound(array_cargas)).sentido = Sheets("Datos Generales").Range("W" & i).Value
array_cargas(UBound(array_cargas)).valor = Sheets("Datos Generales").Range("X" & i).Value
Next i
Dim hoja As Worksheet
For i = 1 To n_elementos
'Genera una hoja nueva
Set hoja = ActiveWorkbook.Sheets.Add
'La movemos al final
ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
Application.ScreenUpdating = True
'Le damos nombre
hoja.Name = "Elemento" & i
'Rellenamos las casillas
Range("A1").Value = "Coordenadas"
Range("A2").Value = "Nodo"
Range("B2").Value = "X"
Range("C2").Value = "Y"
Range("A7").Value = "Espesor"
Range("A9").Value = "Material"
Range("A13").Value = "Tensión plana"
Range("A18").Value = "Deformación plana"
Range("A23").Value = "Matriz B"
Range("A28").Value = "Matriz de rigidez"
Range("F15").Value = "Matriz B transpuesta"
Range("J15").Value = "Btrans*D"
Range("N15").Value = "Btrans*D*B"
Range("J23").Value = "D*B"
Range("J28").Value = "d"
Range("E4").Value = "Area"
Range("A10").Value = "E"
Range("A11").Value = "v"
Range("A15").Value = "D"
Range("A20").Value = "D"
Range("A25").Value = "B"
Range("A32").Value = "K"
Range("F10").Value = "a1"
Range("F11").Value = "a2"
Range("F12").Value = "a3"
Range("H10").Value = "b1"
Range("H11").Value = "b2"
Range("H12").Value = "b3"
Range("J10").Value = "c1"
Range("J11").Value = "c2"
Range("J12").Value = "c3"
Range("A3").FormulaLocal = "='Datos generales'!F" & CStr(i + 2)
Range("A4").FormulaLocal = "='Datos generales'!G" & CStr(i + 2)
Range("A5").FormulaLocal = "='Datos generales'!H" & CStr(i + 2)
Range("B3").FormulaLocal
Range("C3").FormulaLocal
Range("B4").FormulaLocal
Range("C4").FormulaLocal
=
=
=
=
"=BUSCARV(A3;'Datos
"=BUSCARV(A3;'Datos
"=BUSCARV(A4;'Datos
"=BUSCARV(A4;'Datos
generales'!A3:C"
generales'!A3:C"
generales'!A3:C"
generales'!A3:C"
&
&
&
&
(n_nodos
(n_nodos
(n_nodos
(n_nodos
+
+
+
+
2)
2)
2)
2)
&
&
&
&
";2)"
";3)"
";2)"
";3)"
Range("B5").FormulaLocal = "=BUSCARV(A5;'Datos generales'!A3:C" & (n_nodos + 2) & ";2)"
Range("C5").FormulaLocal = "=BUSCARV(A5;'Datos generales'!A3:C" & (n_nodos + 2) & ";3)"
Range("B7").FormulaLocal = "='Datos generales'!I" & CStr(i + 2)
Range("B9").FormulaLocal = "=BUSCARV(" & i & ";'Datos generales'!E3:J" & (n_nodos + 2) & ";6)"
Range("B10").FormulaLocal = "=BUSCARV(B9;'Datos generales'!L3:N" & (n_nodos + 2) & ";2)"
Range("B11").FormulaLocal = "=BUSCARV(B9;'Datos generales'!L3:N" & (n_nodos + 2) & ";3)"
Range("E5").FormulaLocal = "=ABS(0,5*(((1*B4*C5)+(B3*C4*1)+(1*B5*C3))-((C3*B4*1)+(B3*1*C5)+(1*B5*C4))))"
Range("B14").FormulaLocal
Range("B15").FormulaLocal
Range("B16").FormulaLocal
Range("C14").FormulaLocal
Range("C15").FormulaLocal
Range("C16").FormulaLocal
Range("D14").FormulaLocal
Range("D15").FormulaLocal
Range("D16").FormulaLocal
=
=
=
=
=
=
=
=
=
"=($B$10/(1-$B$11^2))*(1)"
"=($B$10/(1-$B$11^2))*($B$11)"
"0"
"=($B$10/(1-$B$11^2))*($B$11)"
"=($B$10/(1-$B$11^2))*(1)"
"0"
"0"
"0"
"=($B$10/(1-$B$11^2))*((1-$B$11)/2)"
Range("B19").FormulaLocal
Range("B20").FormulaLocal
Range("B21").FormulaLocal
Range("C19").FormulaLocal
Range("C20").FormulaLocal
Range("C21").FormulaLocal
Range("D19").FormulaLocal
Range("D20").FormulaLocal
Range("D21").FormulaLocal
=
=
=
=
=
=
=
=
=
"=(($B$10*(1-$B$11))/((1+$B$11)*(1-2*$B$11)))*(1)"
"=(($B$10*(1-$B$11))/((1+$B$11)*(1-2*$B$11)))*(($B$11)/(1-$B$11))"
"0"
"=(($B$10*(1-$B$11))/((1+$B$11)*(1-2*$B$11)))*(($B$11)/(1-$B$11))"
"=(($B$10*(1-$B$11))/((1+$B$11)*(1-2*$B$11)))*(1)"
"0"
"0"
"0"
"=(($B$10*(1-$B$11))/((1+$B$11)*(1-2*$B$11)))*((1-2*$B$11)/(2-2*$B$11))"
Range("G10").FormulaLocal
Range("G11").FormulaLocal
Range("G12").FormulaLocal
Range("I10").FormulaLocal
Range("I11").FormulaLocal
Range("I12").FormulaLocal
Range("K10").FormulaLocal
Range("K11").FormulaLocal
Range("K12").FormulaLocal
=
=
=
=
=
=
=
=
=
"=(B4*C5)-(B5*C4)"
"=(B5*C3)-(B3*C5)"
"=(B3*C4)-(B4*C3)"
"=C4-C5"
"=C5-C3"
"=C3-C4"
"=B5-B4"
"=B3-B5"
"=B4-B3"
Range("B24").FormulaLocal
Range("B25").FormulaLocal
Range("B26").FormulaLocal
Range("C24").FormulaLocal
Range("C25").FormulaLocal
Range("C26").FormulaLocal
=
=
=
=
=
=
"=0,5*I10/$E$5"
"=0/$E$5"
"=0,5*K10/$E$5"
"=0/$E$5"
"=0,5*K10/$E$5"
"=0,5*I10/$E$5"
Range("D24").FormulaLocal
Range("D25").FormulaLocal
Range("D26").FormulaLocal
Range("E24").FormulaLocal
Range("E25").FormulaLocal
Range("E26").FormulaLocal
Range("F24").FormulaLocal
Range("F25").FormulaLocal
Range("F26").FormulaLocal
Range("G24").FormulaLocal
Range("G25").FormulaLocal
Range("G26").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
"=0,5*I11/$E$5"
"=0/$E$5"
"=0,5*K11/$E$5"
"=0/$E$5"
"=0,5*K11/$E$5"
"=0,5*I11/$E$5"
"=0,5*I12/$E$5"
"=0/$E$5"
"=0,5*K12/$E$5"
"=0/$E$5"
"=0,5*K12/$E$5"
"=0,5*I12/$E$5"
Range("F16:H21").Select
Selection.FormulaArray = "=TRANSPOSE(R[8]C[-4]:R[10]C[1])" 'RC[-4]...misma fila, columna, la que estamos -4
Range("J16:L21").Select
Selection.FormulaArray = "=MMULT(RC[-4]:R[5]C[-2],R[-2]C[-8]:RC[-6])"
Range("N16:S21").Select
Selection.FormulaArray = "=MMULT(RC[-4]:R[5]C[-2],R[8]C[-12]:R[10]C[-7])"
Range("J24:O26").Select
Selection.FormulaArray = "=MMULT(R[-10]C[-8]:R[-8]C[-6],RC[-8]:R[2]C[-3])"
Range("N4").FormulaLocal
Range("N5").FormulaLocal
Range("N6").FormulaLocal
Range("N7").FormulaLocal
Range("N8").FormulaLocal
Range("N9").FormulaLocal
=
=
=
=
=
=
"=E5*B7"
"0"
"0"
"0"
"0"
"0"
Range("O4").FormulaLocal
Range("O5").FormulaLocal
Range("O6").FormulaLocal
Range("O7").FormulaLocal
Range("O8").FormulaLocal
Range("O9").FormulaLocal
=
=
=
=
=
=
"0"
"=E5*B7"
"0"
"0"
"0"
"0"
Range("P4").FormulaLocal
Range("P5").FormulaLocal
Range("P6").FormulaLocal
Range("P7").FormulaLocal
Range("P8").FormulaLocal
Range("P9").FormulaLocal
=
=
=
=
=
=
"0"
"0"
"=E5*B7"
"0"
"0"
"0"
Range("Q4").FormulaLocal = "0"
Range("Q5").FormulaLocal
Range("Q6").FormulaLocal
Range("Q7").FormulaLocal
Range("Q8").FormulaLocal
Range("Q9").FormulaLocal
=
=
=
=
=
"0"
"0"
"=E5*B7"
"0"
"0"
Range("R4").FormulaLocal
Range("R5").FormulaLocal
Range("R6").FormulaLocal
Range("R7").FormulaLocal
Range("R8").FormulaLocal
Range("R9").FormulaLocal
=
=
=
=
=
=
"0"
"0"
"0"
"0"
"=E5*B7"
"0"
Range("S4").FormulaLocal
Range("S5").FormulaLocal
Range("S6").FormulaLocal
Range("S7").FormulaLocal
Range("S8").FormulaLocal
Range("S9").FormulaLocal
=
=
=
=
=
=
"0"
"0"
"0"
"0"
"0"
"=E5*B7"
Range("B30:G35").Select
Selection.FormulaArray = "=MMULT(R[-26]C[12]:R[-21]C[17],R[-14]C[12]:R[-9]C[17])"
Range("B29").FormulaLocal
Range("C29").FormulaLocal
Range("D29").FormulaLocal
Range("E29").FormulaLocal
Range("F29").FormulaLocal
Range("G29").FormulaLocal
=
=
=
=
=
=
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
&
&
&
&
&
&
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
&
&
&
&
&
&
"u"
"v"
"u"
"v"
"u"
"v"
&
&
&
&
&
&
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
&
&
&
&
&
&
";A3)"
";A3)"
";A4)"
";A4)"
";A5)"
";A5)"
Range("H30").FormulaLocal
Range("H31").FormulaLocal
Range("H32").FormulaLocal
Range("H33").FormulaLocal
Range("H34").FormulaLocal
Range("H35").FormulaLocal
Next i
End Function
=
=
=
=
=
=
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
&
&
&
&
&
&
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
&
&
&
&
&
&
"u"
"v"
"u"
"v"
"u"
"v"
&
&
&
&
&
&
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
&
&
&
&
&
&
";A3)"
";A3)"
";A4)"
";A4)"
";A5)"
";A5)"
Option Explicit
Public Type Carga
n As Integer
nodo As Integer
sentido As String
valor As Double
End Type
Public Type Elemento
n As Integer
nodo1 As Integer
nodo2 As Integer
nodo3 As Integer
nodo4 As Integer
End Type
Public Type Apoyo
nodo As String
X As String
Y As String
End Type
Private Function lee_INP()
Dim myFile As String, text As String, textline As String, posLat As Integer, posLong As Integer
Dim Definicion_nodos As Boolean
Dim Definicion_elementos As Boolean
Dim Definicion_espesor As Boolean
Dim Definicion_material As Boolean
Dim Definicion_grupo As Boolean
Dim Definicion_apoyo As Boolean
Dim Definicion_carga As Boolean
Dim i As Integer
Dim grupos() As String
ReDim grupos(0)
Dim apoyos() As Apoyo
ReDim apoyos(0)
Dim cargas() As Carga
ReDim cargas(0)
Definicion_nodos = False
Definicion_elementos = False
Definicion_espesor = False
Definicion_material = False
Definicion_grupo = False
Definicion_apoyo = False
Definicion_carga = False
Dim n_nodos As Integer
Dim n_elementos As Integer
n_nodos = 0
n_elementos = 0
'Borramos todos los datos existentes
Range("A3:Y65590").Select
Selection.Delete
Dim STR As String
Dim V As Variant
myFile = Application.GetOpenFilename()
'Movemos los botones
Application.Sheets("Datos generales").Activate
Columns("A:E").Select
Dim dist_a_izda As Double
dist_a_izda = Selection.Width
Mueve_botones (dist_a_izda)
Open myFile For Input As #1
Do Until EOF(1)
Line Input #1, textline
text = textline
If (Definicion_nodos = True) And (IsNumeric(Trim(Left(text, 7)))) Then 'Esta linea define un nodo
n_nodos = n_nodos + 1
Range(rango(n_nodos + 2, 1)) = Trim(Left(text, 7)) 'Nº de nodo
STR = Right(text, 27) ' Aquí tomo todo lo que hay a la derecha de la primera coma
STR = Trim(Left(STR, 13)) ' Aquí tomo todo lo que hay a la izquierda de la segunda coma
'STR = Replace(STR, ".", ",")
Range(rango(n_nodos + 2, 2)) = Val(STR) 'Coordenada X del nodo
STR = Trim(Right(text, 13))
'STR = Replace(STR, ".", ",")
Range(rango(n_nodos + 2, 3)) = Val(STR) 'Coordenada Y del nodo
Else
Definicion_nodos = False
End If
If (Definicion_elementos = True) And (IsNumeric(Trim(Left(text, 3)))) Then 'Esta linea define un elemento
n_elementos = n_elementos + 1
Range(rango(n_elementos + 2, 5)) = Trim(Left(text, 3)) 'Nº de elemento
STR = Right(text, Len(text) - 4) ' Aquí tomo todo lo que hay a la derecha de la primera coma
Range(rango(n_elementos + 2, 6)) = Trim(Left(STR, 4)) 'Nodo 1
STR = Right(STR, 14) ' Aquí tomo todo lo que hay a la derecha de la primera coma
Range(rango(n_elementos + 2, 7)) = Trim(Left(STR, 4)) 'Nodo 2
STR = Right(STR, 9) ' Aquí tomo todo lo que hay a la derecha de la primera coma
Range(rango(n_elementos + 2, 8)) = Trim(Left(STR, 4)) 'Nodo 3
STR = Right(STR, 4) ' Aquí tomo todo lo que hay a la derecha de la primera coma
Range(rango(n_elementos + 2, 9)) = Trim(STR) 'Nodo 4
Else
Definicion_elementos = False
End If
If (Definicion_espesor = True) And (IsNumeric(Val(text))) Then 'Esta linea define el espesor
For i = 1 To n_elementos
Range(rango(i + 2, 10)) = Trim(Left(text, (Len(text) - 1))) 'Espesor del elemento
Range(rango(i + 2, 11)) = "1" 'Material del elemento"
Next i
Definicion_espesor = False
End If
If (Definicion_material = True) And (IsNumeric(Trim(Left(text, 1)))) Then 'Esta linea define el material
Range(rango(3, 13)) = "1" 'Nº de Material "
Range(rango(3, 14)) = Trim(Left(text, (InStr(1, text, ",") - 1))) 'Módulo de Young
Range(rango(3, 15)) = Trim(Right(text, (Len(text) - InStr(1, text, ",")))) 'Módulo de Poisson
Else
Definicion_material = False
End If
If (Definicion_grupo = True) And (IsNumeric(Trim(Left(text, 5)))) Then 'Esta linea define un grupo
If Right(text, 1) = "," Then
grupos(UBound(grupos)) = Left(text, Len(text) - 1)
Else
grupos(UBound(grupos)) = text
End If
Else
Definicion_grupo = False
End If
If (Definicion_apoyo = True) And ((Trim(Left(text, 10))) = "_PickedSet") Then 'Esta linea define un apoyo
STR = Left(text, InStr(text, ",") - 1)
STR = Right(STR, Len(STR) - 10)
V = Split(grupos(STR), ",")
STR = Right(text, 1)
For i = 1 To UBound(V) + 1
If apoyos(UBound(apoyos)).nodo = "" Then 'Es el primer apoyo definido
apoyos(UBound(apoyos)).nodo = Trim(CStr(V(i - 1)))
If STR = 1 Then
apoyos(UBound(apoyos)).X = 0
ElseIf STR = 2 Then
apoyos(UBound(apoyos)).Y = 0
End If
Else 'No es el primer apoyo definido
'Comprueba que este nodo no existe en las condiciones de contorno
For j = 0 To UBound(apoyos)
If apoyos(j).nodo = Trim(CStr(V(i - 1))) Then
encontrado = True
If STR = 1 Then
apoyos(j).X = 0
ElseIf STR = 2 Then
apoyos(j).Y = 0
End If
Exit For
End If
Next j
If encontrado = False Then
ReDim Preserve apoyos(UBound(apoyos) + 1)
apoyos(UBound(apoyos)).nodo = Trim(CStr(V(i - 1)))
If STR = 1 Then
apoyos(UBound(apoyos)).X = 0
ElseIf STR = 2 Then
apoyos(UBound(apoyos)).Y = 0
End If
End If
End If
Next i
Else
Definicion_apoyo = False
End If
If (Definicion_carga = True) And ((Trim(Left(text, 10))) = "_PickedSet") Then 'Esta linea define una carga
STR = Left(text, InStr(text, ",") - 1)
STR = Right(STR, Len(STR) - 10)
V = Split(grupos(STR), ",")
STR = Trim(Right(text, Len(text) - 12))
For i = 1 To UBound(V) + 1
If cargas(UBound(cargas)).n = 0 Then 'Es el primer apoyo definido
Else 'No es el primer apoyo definido
ReDim Preserve cargas(UBound(cargas) + 1)
End If
cargas(UBound(cargas)).n = i
cargas(UBound(cargas)).nodo = CInt(Trim(CStr(V(i - 1))))
If Left(STR, 1) = "1" Then
cargas(UBound(cargas)).sentido = "X"
ElseIf Left(STR, 1) = "2" Then
cargas(UBound(cargas)).sentido = "Y"
End If
cargas(UBound(cargas)).valor = CDbl(Trim(Right(STR, Len(STR) - 2)))
Next i
End If
If text = "*Node" Then 'Empieza la definicion de nodos
Definicion_nodos = True
End If
If Left(text, 9) = "*Element," Then 'Empieza la definicion de elementos
Definicion_nodos = False
Definicion_elementos = True
End If
If Left(text, 14) = "*Solid Section" Then 'Empieza la definicion del espesor
Definicion_nodos = False
Definicion_elementos = False
Definicion_espesor = True
End If
If Left(text, 8) = "*Elastic" Then 'Empieza la definicion del material
Definicion_nodos = False
Definicion_elementos = False
Definicion_espesor = False
Definicion_material = True
End If
If Left(text, 22) = "*Nset, nset=_PickedSet" Then 'Empieza la definicion de un grupo
Definicion_nodos = False
Definicion_elementos = False
Definicion_espesor = False
Definicion_material = False
Definicion_grupo = True
STR = Left(text, (InStr(1, text, ", internal") - 1))
STR = Right(STR, Len(STR) - 22)
ReDim Preserve grupos(Val(STR))
End If
If Left(text, 9) = "*Boundary" Then 'Empieza la definicion de un apoyo
Definicion_nodos = False
Definicion_elementos = False
Definicion_espesor = False
Definicion_material = False
Definicion_grupo = False
Definicion_apoyo = True
End If
If Left(text, 8) = "** LOADS" Then 'Empieza la definicion de cargas
Definicion_nodos = False
Definicion_elementos = False
Definicion_espesor = False
Definicion_material = False
Definicion_grupo = False
Definicion_apoyo = False
Definicion_carga = True
End If
Loop
Close #1
For i = 0 To UBound(apoyos)
Range(rango(i + 3, 17)).Value = CStr(i + 1)
Range(rango(i + 3, 18)).Value = CStr(apoyos(i).nodo)
If apoyos(i).X = "" Then
Range(rango(i +
Else
Range(rango(i +
End If
If apoyos(i).Y = ""
Range(rango(i +
Else
Range(rango(i +
End If
Next i
3, 19)).Value = "???"
3, 19)).Value = CStr(apoyos(i).X)
Then
3, 20)).Value = "???"
3, 20)).Value = CStr(apoyos(i).Y)
For i = 0 To UBound(cargas)
Range(rango(i + 3, 22)).Value
Range(rango(i + 3, 23)).Value
Range(rango(i + 3, 24)).Value
Range(rango(i + 3, 25)).Value
Next i
=
=
=
=
CStr(cargas(i).n)
CStr(cargas(i).nodo)
CStr(cargas(i).sentido)
CStr(cargas(i).valor)
End Function
Private Function ensambla_k_reducida()
Application.Sheets("Datos generales").Activate
Dim n_apoyos As Integer
n_apoyos = Range("T1").Value
Dim n_cargas As Integer
n_cargas = Range("X1").Value
'Copiamos la matriz de rigidez completa
Worksheets("Matriz global de rigidez").Copy After:=Sheets(Sheets.Count)
Dim hoja As Worksheet
Set hoja = ActiveWorkbook.Sheets("Matriz global de rigidez (2)")
'La movemos al final
hoja.Activate
ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
Application.ScreenUpdating = True
'Le damos nombre
hoja.Name = "Matriz rigidez reducida"
'Copiamos todas las celdas escritas, y pegamos en el mismo area valores y formatos
Dim i As Integer
Dim j As Integer
'Borramos las filas y las columnas que tengan desplazamientos y giros conocidos
Dim filas_borrar() As Integer
Dim inicio As Integer
Dim filaX As Integer
Dim filaY As Integer
Application.Sheets("Datos generales").Activate
ReDim filas_borrar(0)
For i = 1 To n_apoyos
If Range(rango((i + 2), 17)).Value <> "" Then 'Empieza definicion de apoyo
If Range(rango((i + 2), 18)).Value <> "" Then 'Define el nº de nodo
filaX = 0
filaY = 0
inicio = CInt(Range(rango((i + 2), 18)).Value) 'nº de nodo
If Range(rango((i + 2), 19)).Value = 0 Then
filaX = inicio * 2 'coordenada X
End If
If Range(rango((i + 2), 20)).Value = 0 Then
filaY = (inicio * 2) + 1 'coordenada Y
End If
If filaX <> 0 Then
If filas_borrar(UBound(filas_borrar)) <> 0 Then
ReDim Preserve filas_borrar(UBound(filas_borrar) + 1)
End If
filas_borrar(UBound(filas_borrar)) = filaX
End If
If filaY <> 0 Then
If filas_borrar(UBound(filas_borrar)) <> 0 Then
ReDim Preserve filas_borrar(UBound(filas_borrar) + 1)
End If
filas_borrar(UBound(filas_borrar)) = filaY
End If
End If
End If
Next i
Application.Sheets("Matriz rigidez reducida").Activate
'Borramos las filas y columnas especificadas en el array filas_borrar
Dim STR As String
STR = ""
For i = 0 To UBound(filas_borrar)
If i = UBound(filas_borrar) Then
STR = STR & rango(1, filas_borrar(i))
Else
STR = STR & rango(1, filas_borrar(i)) & ","
End If
Next i
Range(STR).EntireColumn.Select
Selection.EntireColumn.Delete
STR = ""
For i = 0 To UBound(filas_borrar)
If i = UBound(filas_borrar) Then
STR = STR & rango(filas_borrar(i), 1)
Else
STR = STR & rango(filas_borrar(i), 1) & ","
End If
Next i
Range(STR).EntireRow.Select
Selection.EntireRow.Delete
Range("A:A").Select
Selection.Insert Shift:=xlRight
'Resolvemos por gauss-jordan
'Gauss_jordan
'Resolvemos por k_inversa
K_inversa
End Function
Private Function K_inversa()
Application.Sheets("Matriz rigidez reducida").Activate
Dim n_filas As Integer
Dim k As String
Dim i As Integer
n_filas = Application.CountA(Range("B1:B65536"))
Dim rang As String
rang = "C" & CStr(n_filas + 4) & ":" & rango(n_filas + 3 + n_filas, n_filas + 2)
k = "=MINVERSE(R[-" & (n_filas + 2) & "]C[]:R[-3]C[" & (n_filas - 1) & "])"
Range(rang).Select
Selection.FormulaArray = k
'Una vez termina el calculo de la matriz inversa colocamos los resultados
Dim col As Integer
col = n_filas + 5
Range(rango(1, col)).Value = "Desplz"
Range(rango(1, col + 1)).Value = "Valor"
For i = 1 To n_filas
Range(rango(i + 1, col)).FormulaLocal = "=B" & i + 1
Next i
rang = rango(2, col + 1) & ":" & rango(n_filas + 1, col + 1)
k = "=MMULT(R[" & (n_filas + 2) & "]C[" & (-n_filas - 3) & "]:R[" & (2 * n_filas + 1) & "]C[" & (-4) & "],R[]C[3]:R[" & (n_filas - 1) & "]C[-3])"
Range(rang).Select
Selection.FormulaArray = k
End Function
Private Function Gauss_jordan()
Application.Sheets("Matriz rigidez reducida").Activate
Dim n_veces As Integer
Dim i As Integer
Dim k As Integer
Dim j As Integer
Dim fila As Integer
n_veces = Application.CountA(Range("B1:B65536"))
'Hay que hacer el pivotamiento n_veces
For i = 1 To n_veces
fila = ((i * (n_veces + 2)) + 1 + i)
Range(rango(fila, 3) & ":" & rango(fila, (n_veces + 3))).FormulaArray = "=" & rango((fila - n_veces - 2), 3) &
":" & rango((fila - n_veces - 2), (n_veces + 3)) & "/" & rango((fila - n_veces - 2), (i + 2))
'Rellena las filas inferiores
For k = (fila + 1) To (n_veces + fila - i)
For j = 3 To n_veces + 3
Range(rango(k, j)).FormulaLocal = "=" & rango((k - n_veces - 2), j) & "-(" & _
rango((k - n_veces - 2), (i + 2)) & "*" & rango(fila, j) & ")"
Next j
Next k
'Rellena las filas superiores
For k = (fila - i + 1) To (fila - 1) 'Cdo i=1 no entra en el bucle..ok
For j = 3 To n_veces + 3
Range(rango(k, j)).FormulaLocal = "=" & rango((k - n_veces - 2), j) & "-(" & _
rango((k - n_veces - 2), (i + 2)) & "*" & rango(fila, j) & ")"
Next j
Next k
Next i
'Una vez termina el pivotamiento resumimos los resultados
Dim col As Integer
col = n_veces + 5
Range(rango(1, col)).Value = "Desplz"
Range(rango(1, col + 1)).Value = "Valor"
For i = 1 To n_veces
Range(rango(i + 1, col)).FormulaLocal = "=B" & i + 1
Range(rango(i + 1, col + 1)).FormulaLocal = "=" & rango(k + i - n_veces, n_veces + 3)
Next i
End Function
Private Function calcula_resultados()
Application.Sheets("Datos generales").Activate
Dim n_elementos As Integer
Dim n_nodos As Integer
Dim i As Integer
n_elementos = Range("G1").Value
n_nodos = Range("C1").Value
'Genera una hoja nueva
Dim hoja As Worksheet
Set hoja = ActiveWorkbook.Sheets.Add
'La movemos al final
ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
Application.ScreenUpdating = True
'Le damos nombre
hoja.Name = "Resultados"
ActiveSheet.Cells(1, 1).Value = "Nodo"
ActiveSheet.Cells(1, 2).Value = "X_ini"
ActiveSheet.Cells(1, 3).Value = "Y_ini"
ActiveSheet.Cells(1, 4).Value = "Desp_X"
ActiveSheet.Cells(1, 5).Value = "Desp_Y"
ActiveSheet.Cells(1, 6).Value = "X_fin"
ActiveSheet.Cells(1, 7).Value = "Y_fin"
ActiveSheet.Cells(1, 8).Value = "Escala"
ActiveSheet.Cells(2, 8).Value = 1000
Range("A2:C" & n_nodos + 1).Select
Selection.FormulaArray = "='Datos generales'!A3:C" & n_nodos + 2
Dim formula_X As String
Dim formula_Y As String
Dim n_veces As Integer
n_veces = Application.CountA(Range("'Matriz rigidez reducida'!B1:B65536"))
For i = 1 To n_nodos
formula_X = "INDICE('Matriz rigidez reducida'!" & rango(2, n_veces + 5) & ":" & Split(Columns(n_veces +
6).Address(, False), ":")(1) & n_veces + 1 & ";COINCIDIR(" & Chr(34) & "u" & i & Chr(34) & ";'Matriz rigidez reducida'!"
& rango(2, n_veces + 5) & ":" & Split(Columns(n_veces + 5).Address(, False), ":")(1) & n_veces + 1 & ";0);2))"
formula_X = "=SI(ESERROR(" & formula_X & ";0;(" & formula_X & ")"
Range(rango(i + 1, 4)).FormulaLocal = formula_X
formula_Y = "INDICE('Matriz rigidez reducida'!" & rango(2, n_veces + 5) & ":" & Split(Columns(n_veces +
6).Address(, False), ":")(1) & n_veces + 1 & ";COINCIDIR(" & Chr(34) & "v" & i & Chr(34) & ";'Matriz rigidez reducida'!"
& rango(2, n_veces + 5) & ":" & Split(Columns(n_veces + 5).Address(, False), ":")(1) & n_veces + 1 & ";0);2))"
formula_Y = "=SI(ESERROR(" & formula_Y & ";0;(" & formula_Y & ")"
Range(rango(i + 1, 5)).FormulaLocal = formula_Y
Range(rango(i + 1, 6)).FormulaLocal = "=" & rango(i + 1, 2) & "+" & "$H$2*" & rango(i + 1, 4)
Range(rango(i + 1, 7)).FormulaLocal = "=" & rango(i + 1, 3) & "+" & "$H$2*" & rango(i + 1, 5)
Next i
Dim array_elementos() As Elemento
For i = 1 To n_elementos
If i = 1 Then
ReDim array_elementos(0)
Else
ReDim Preserve array_elementos(UBound(array_elementos) + 1)
End If
array_elementos(UBound(array_elementos)).n = Sheets("Datos Generales").Range("E" & i
array_elementos(UBound(array_elementos)).nodo1 = Sheets("Datos Generales").Range("F"
array_elementos(UBound(array_elementos)).nodo2 = Sheets("Datos Generales").Range("G"
array_elementos(UBound(array_elementos)).nodo3 = Sheets("Datos Generales").Range("H"
array_elementos(UBound(array_elementos)).nodo4 = Sheets("Datos Generales").Range("I"
Next i
'Creamos un grafico de barras
Dim j As Integer
Dim chrt As ChartObject
Set chrt = ActiveSheet.ChartObjects.Add _
(Left:=100, Width:=750, Top:=130, Height:=440)
chrt.Chart.ChartType = xlXYScatterLinesNoMarkers
'Dibujamos la configuracion deformada
+
&
&
&
&
2).Value
i + 2).Value
i + 2).Value
i + 2).Value
i + 2).Value
i = 1
For j = 1 To n_elementos
chrt.Chart.SeriesCollection.NewSeries
chrt.Chart.SeriesCollection(j + i - 1).XValues = "=Resultados!$F$" & (array_elementos(j - 1).nodo1 + 1) & _
",Resultados!$F$" & (array_elementos(j - 1).nodo2 + 1) & _
",Resultados!$F$" & (array_elementos(j - 1).nodo3 + 1) & _
",Resultados!$F$" & (array_elementos(j - 1).nodo4 + 1) & _
",Resultados!$F$" & (array_elementos(j - 1).nodo1 + 1)
chrt.Chart.SeriesCollection(j + i - 1).Values = "=Resultados!$G$" & (array_elementos(j - 1).nodo1 + 1) & _
",Resultados!$G$" & (array_elementos(j - 1).nodo2 + 1) & _
",Resultados!$G$" & (array_elementos(j - 1).nodo3 + 1) & _
",Resultados!$G$" & (array_elementos(j - 1).nodo4 + 1) & _
",Resultados!$G$" & (array_elementos(j - 1).nodo1 + 1)
chrt.Chart.Axes(xlCategory).HasMinorGridlines = False
chrt.Chart.Axes(xlValue).HasMajorGridlines = False
chrt.Chart.Axes(xlValue).HasMinorGridlines = False
chrt.Chart.HasLegend = False
chrt.Chart.SeriesCollection(j + i - 1).Format.Line.Weight = 2
chrt.Chart.SeriesCollection(j + i - 1).Border.Color = RGB(255, 0, 0)
Next j
Dim max As Double
max = CInt(Application.WorksheetFunction.max(Range("B2:G" & n_nodos + 1)))
chrt.Chart.Axes(xlCategory).HasMajorGridlines = True
chrt.Chart.Axes(xlCategory).HasMinorGridlines = True
chrt.Chart.Axes(xlValue).HasMajorGridlines = True
chrt.Chart.Axes(xlValue).HasMinorGridlines = True
End Function
Private Function ensambla_matriz_completa()
Application.Sheets("Datos generales").Activate
Dim n_elementos As Integer
Dim n_nodos As Integer
Dim n_cargas As Integer
Dim i As Integer
n_elementos = Range("G1").Value
n_nodos = Range("C1").Value
n_cargas = Range("X1").Value
Dim array_cargas() As Carga
For i = 3 To n_cargas + 2
If i = 3 Then
ReDim array_cargas(0)
Else
ReDim Preserve array_cargas(UBound(array_cargas) + 1)
End If
array_cargas(UBound(array_cargas)).n = Sheets("Datos Generales").Range("V" & i).Value
array_cargas(UBound(array_cargas)).nodo = Sheets("Datos Generales").Range("W" & i).Value
array_cargas(UBound(array_cargas)).sentido = Sheets("Datos Generales").Range("X" & i).Value
array_cargas(UBound(array_cargas)).valor = Sheets("Datos Generales").Range("Y" & i).Value
Next i
'Genera una hoja nueva
Dim hoja As Worksheet
Set hoja = ActiveWorkbook.Sheets.Add
'La movemos al final
ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
Application.ScreenUpdating = True
'Le damos nombre
hoja.Name = "Matriz global de rigidez"
Dim j As Integer
Dim k As Integer
For i = 1 To n_nodos
ActiveSheet.Cells((2 * i), 1).FormulaLocal = "=CONCATENAR(" & Chr(34) & "u"
CStr(i + 2) & ")"
ActiveSheet.Cells((2 * i + 1), 1).FormulaLocal = "=CONCATENAR(" & Chr(34) &
generales'!A" & CStr(i + 2) & ")"
Next i
For i = 1 To n_nodos
ActiveSheet.Cells(1, (2 * i)).FormulaLocal = "=CONCATENAR(" & Chr(34) & "u"
CStr(i + 2) & ")"
ActiveSheet.Cells(1, (2 * i + 1)).FormulaLocal = "=CONCATENAR(" & Chr(34) &
generales'!A" & CStr(i + 2) & ")"
Next i
k = 2 * i
ActiveSheet.Cells(1, k).Value = "Fuerzas"
& Chr(34) & ";'Datos generales'!A" &
"v" & Chr(34) & ";'Datos
& Chr(34) & ";'Datos generales'!A" &
"v" & Chr(34) & ";'Datos
'Ensamablamos las cargas en los nodos
For i = 2 To ((2 * n_nodos) + 1) 'filas
Range(rango(i, k)).FormulaLocal = "=0"
Next i
For j = 1 To n_cargas 'filas
i = (Sheets("Datos generales").Range(rango(j + 2, 23)).Value) * 2
If Sheets("Datos generales").Range(rango(j + 2, 24)).Value = "Y" Then
i = i + 1
End If
Sheets("Matriz global de rigidez").Select
Range(rango(i, k)).FormulaLocal = Range(rango(i, k)).FormulaLocal & "+'Datos generales'!Y" & CStr(j + 2)
Next j
'
'Ensamblamos las rigideces de los elementos
Dim formula As String
Dim fila As Integer
Dim columna As Integer
Dim valor As Double
Dim formula1 As String
Dim cadena_elemento As String
Dim z As Integer
For i = 2 To ((2 * n_nodos) + 1) 'filas
For j = 2 To ((2 * n_nodos) + 1) 'columnas
Range(rango(i, j)).Value = 0
Next j
Next i
Dim nodo1 As Integer
Dim nodo2 As Integer
Dim nodo3 As Integer
Dim nodo4 As Integer
Dim rig As Double
For k = 1 To n_elementos
'En la hoja de cada elemento, vemos que nodos tiene el elemento en cuestion
cadena_elemento = "Elemento" & CStr(k)
nodo1 = Sheets(cadena_elemento).Range("A3").Value
nodo2 = Sheets(cadena_elemento).Range("A4").Value
nodo3 = Sheets(cadena_elemento).Range("A5").Value
nodo4 = Sheets(cadena_elemento).Range("A6").Value
Sheets("Matriz global de rigidez").Select
'Actuamos sobre la fila x del nodo 1
fila = 2 * nodo1 - 1 + 1
'Actuamos en las 8 columnas que tocan en esta fila
'Columna 1
columna = 2 * nodo1 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("B25").Value
'Columna 2
columna = 2 * nodo1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("C25").Value
'Columna 3
columna = 2 * nodo2 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("D25").Value
'Columna 4
columna = 2 * nodo2 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("E25").Value
'Columna 5
columna = 2 * nodo3 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("F25").Value
'Columna 6
columna = 2 * nodo3 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("G25").Value
'Columna 7
columna = 2 * nodo4 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("H25").Value
'Columna 8
columna = 2 * nodo4 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("I25").Value
'Actuamos sobre la fila y del nodo 1
fila = 2 * nodo1 + 1
'Actuamos en las 6 columnas que tocan en esta
'Columna 1
columna = 2 * nodo1 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 2
columna = 2 * nodo1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 3
columna = 2 * nodo2 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 4
columna = 2 * nodo2 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 5
columna = 2 * nodo3 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 6
columna = 2 * nodo3 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 7
columna = 2 * nodo4 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 8
columna = 2 * nodo4 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Actuamos sobre la fila x del nodo 2
fila
Sheets(cadena_elemento).Range("B26").Value
Sheets(cadena_elemento).Range("C26").Value
Sheets(cadena_elemento).Range("D26").Value
Sheets(cadena_elemento).Range("E26").Value
Sheets(cadena_elemento).Range("F26").Value
Sheets(cadena_elemento).Range("G26").Value
Sheets(cadena_elemento).Range("H26").Value
Sheets(cadena_elemento).Range("I26").Value
fila = 2 * nodo2 - 1 + 1
'Actuamos en las 8 columnas que tocan en esta
'Columna 1
columna = 2 * nodo1 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 2
columna = 2 * nodo1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 3
columna = 2 * nodo2 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 4
columna = 2 * nodo2 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 5
columna = 2 * nodo3 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 6
columna = 2 * nodo3 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 7
columna = 2 * nodo4 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 8
columna = 2 * nodo4 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
fila
Sheets(cadena_elemento).Range("B27").Value
Sheets(cadena_elemento).Range("C27").Value
Sheets(cadena_elemento).Range("D27").Value
Sheets(cadena_elemento).Range("E27").Value
Sheets(cadena_elemento).Range("F27").Value
Sheets(cadena_elemento).Range("G27").Value
Sheets(cadena_elemento).Range("H27").Value
Sheets(cadena_elemento).Range("I27").Value
'Actuamos sobre la fila y del nodo 2
fila = 2 * nodo2 + 1
'Actuamos en las 8 columnas que tocan en esta fila
'Columna 1
columna = 2 * nodo1 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("B28").Value
'Columna 2
columna = 2 * nodo1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("C28").Value
'Columna 3
columna = 2 * nodo2 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 4
columna = 2 * nodo2 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 5
columna = 2 * nodo3 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 6
columna = 2 * nodo3 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 7
columna = 2 * nodo4 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 8
columna = 2 * nodo4 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
+ Sheets(cadena_elemento).Range("D28").Value
+ Sheets(cadena_elemento).Range("E28").Value
+ Sheets(cadena_elemento).Range("F28").Value
+ Sheets(cadena_elemento).Range("G28").Value
+ Sheets(cadena_elemento).Range("H28").Value
+ Sheets(cadena_elemento).Range("I28").Value
'Actuamos sobre la fila x del nodo 3
fila = 2 * nodo3 - 1 + 1
'Actuamos en las 8 columnas que tocan en esta
'Columna 1
columna = 2 * nodo1 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 2
columna = 2 * nodo1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 3
columna = 2 * nodo2 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 4
columna = 2 * nodo2 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 5
columna = 2 * nodo3 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
fila
Sheets(cadena_elemento).Range("B29").Value
Sheets(cadena_elemento).Range("C29").Value
Sheets(cadena_elemento).Range("D29").Value
Sheets(cadena_elemento).Range("E29").Value
Sheets(cadena_elemento).Range("F29").Value
'Columna 6
columna = 2 * nodo3 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("G29").Value
'Columna 7
columna = 2 * nodo4 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("H29").Value
'Columna 8
columna = 2 * nodo4 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("I29").Value
'Actuamos sobre la fila y del nodo 3
fila = 2 * nodo3 + 1
'Actuamos en las 8 columnas que tocan en esta
'Columna 1
columna = 2 * nodo1 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 2
columna = 2 * nodo1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 3
columna = 2 * nodo2 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 4
columna = 2 * nodo2 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 5
columna = 2 * nodo3 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 6
columna = 2 * nodo3 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 7
columna = 2 * nodo4 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 8
columna = 2 * nodo4 + 1
rig = Range(rango(fila, columna)).Value
fila
Sheets(cadena_elemento).Range("B30").Value
Sheets(cadena_elemento).Range("C30").Value
Sheets(cadena_elemento).Range("D30").Value
Sheets(cadena_elemento).Range("E30").Value
Sheets(cadena_elemento).Range("F30").Value
Sheets(cadena_elemento).Range("G30").Value
Sheets(cadena_elemento).Range("H30").Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("I30").Value
'Actuamos sobre la fila x del nodo 4
fila = 2 * nodo4 - 1 + 1
'Actuamos en las 8 columnas que tocan en esta
'Columna 1
columna = 2 * nodo1 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 2
columna = 2 * nodo1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 3
columna = 2 * nodo2 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 4
columna = 2 * nodo2 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 5
columna = 2 * nodo3 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 6
columna = 2 * nodo3 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 7
columna = 2 * nodo4 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
'Columna 8
columna = 2 * nodo4 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig +
fila
Sheets(cadena_elemento).Range("B31").Value
Sheets(cadena_elemento).Range("C31").Value
Sheets(cadena_elemento).Range("D31").Value
Sheets(cadena_elemento).Range("E31").Value
Sheets(cadena_elemento).Range("F31").Value
Sheets(cadena_elemento).Range("G31").Value
Sheets(cadena_elemento).Range("H31").Value
Sheets(cadena_elemento).Range("I31").Value
'Actuamos sobre la fila y del nodo 4
fila = 2 * nodo4 + 1
'Actuamos en las 8 columnas que tocan en esta fila
'Columna 1
columna = 2 * nodo1 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig + Sheets(cadena_elemento).Range("B32").Value
'Columna 2
columna = 2 * nodo1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 3
columna = 2 * nodo2 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 4
columna = 2 * nodo2 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 5
columna = 2 * nodo3 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 6
columna = 2 * nodo3 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 7
columna = 2 * nodo4 - 1 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
'Columna 8
columna = 2 * nodo4 + 1
rig = Range(rango(fila, columna)).Value
Range(rango(fila, columna)).Value = rig
+ Sheets(cadena_elemento).Range("C32").Value
+ Sheets(cadena_elemento).Range("D32").Value
+ Sheets(cadena_elemento).Range("E32").Value
+ Sheets(cadena_elemento).Range("F32").Value
+ Sheets(cadena_elemento).Range("G32").Value
+ Sheets(cadena_elemento).Range("H32").Value
+ Sheets(cadena_elemento).Range("I32").Value
Next k
'Una vez rellena la hoja, disminuyo zoom, deselecciono y la subo arriba del todo
ActiveWindow.Zoom = 70
Range("A1").Select
Application.CutCopyMode = False
End Function
Private Function rango(ByVal fil As Integer, ByVal colum As Integer) As String
Cells(fil, colum).Select
rango = Replace(Application.ActiveCell.Address, "$", "")
End Function
Private Function genera_hojas_elementos()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim n_elementos As Integer
Dim n_nodos As Integer
Dim n_materiales As Integer
Dim n_cargas As Integer
Dim n_apoyos As Integer
n_materiales = Range("O1").Value
n_elementos = Range("G1").Value
n_nodos = Range("C1").Value
n_cargas = Range("X1").Value
Dim array_cargas() As Carga
For i = 3 To n_cargas + 2
If i = 3 Then
ReDim array_cargas(0)
Else
ReDim Preserve array_cargas(UBound(array_cargas) + 1)
End If
array_cargas(UBound(array_cargas)).n = Sheets("Datos Generales").Range("V" & i).Value
array_cargas(UBound(array_cargas)).nodo = Sheets("Datos Generales").Range("W" & i).Value
array_cargas(UBound(array_cargas)).sentido = Sheets("Datos Generales").Range("X" & i).Value
array_cargas(UBound(array_cargas)).valor = Sheets("Datos Generales").Range("Y" & i).Value
Next i
Dim hoja As Worksheet
For i = 1 To n_elementos
'Genera una hoja nueva
Set hoja = ActiveWorkbook.Sheets.Add
'La movemos al final
ActiveSheet.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
Application.ScreenUpdating = True
'Le damos nombre
hoja.Name = "Elemento" & i
'Rellenamos las casillas
Range("A1").Value = "Coordenadas"
Range("A2").Value = "Nodo"
Range("B2").Value = "X"
Range("C2").Value = "Y"
Range("A7").Value = "Espesor"
Range("A9").Value = "Material"
Range("A13").Value = "Tensión plana"
Range("A18").Value = "Deformación plana"
Range("A23").Value = "Matriz de rigidez"
Range("A10").Value = "E"
Range("A11").Value = "v"
Range("A15").Value = "D"
Range("A20").Value = "D"
Range("A28").Value = "K"
Range("A3").FormulaLocal
Range("A4").FormulaLocal
Range("A5").FormulaLocal
Range("A6").FormulaLocal
=
=
=
=
"='Datos
"='Datos
"='Datos
"='Datos
generales'!F"
generales'!G"
generales'!H"
generales'!I"
&
&
&
&
CStr(i
CStr(i
CStr(i
CStr(i
+
+
+
+
2)
2)
2)
2)
Range("B3").FormulaLocal
Range("C3").FormulaLocal
Range("B4").FormulaLocal
Range("C4").FormulaLocal
Range("B5").FormulaLocal
Range("C5").FormulaLocal
Range("B6").FormulaLocal
Range("C6").FormulaLocal
Range("B7").FormulaLocal
=
=
=
=
=
=
=
=
=
"=BUSCARV(A3;'Datos generales'!A3:C"
"=BUSCARV(A3;'Datos generales'!A3:C"
"=BUSCARV(A4;'Datos generales'!A3:C"
"=BUSCARV(A4;'Datos generales'!A3:C"
"=BUSCARV(A5;'Datos generales'!A3:C"
"=BUSCARV(A5;'Datos generales'!A3:C"
"=BUSCARV(A6;'Datos generales'!A3:C"
"=BUSCARV(A6;'Datos generales'!A3:C"
"='Datos generales'!J" & CStr(i + 2)
&
&
&
&
&
&
&
&
(n_nodos
(n_nodos
(n_nodos
(n_nodos
(n_nodos
(n_nodos
(n_nodos
(n_nodos
+
+
+
+
+
+
+
+
2)
2)
2)
2)
2)
2)
2)
2)
&
&
&
&
&
&
&
&
";2)"
";3)"
";2)"
";3)"
";2)"
";3)"
";2)"
";3)"
Range("B9").FormulaLocal = "=BUSCARV(" & i & ";'Datos generales'!E3:K" & (n_nodos + 2) & ";7)"
Range("B10").FormulaLocal = "=BUSCARV(B9;'Datos generales'!M3:O" & (n_nodos + 2) & ";2)"
Range("B11").FormulaLocal = "=BUSCARV(B9;'Datos generales'!M3:O" & (n_nodos + 2) & ";3)"
Range("B14").FormulaLocal
Range("B15").FormulaLocal
Range("B16").FormulaLocal
Range("C14").FormulaLocal
Range("C15").FormulaLocal
Range("C16").FormulaLocal
Range("D14").FormulaLocal
Range("D15").FormulaLocal
Range("D16").FormulaLocal
=
=
=
=
=
=
=
=
=
"=($B$10/(1-$B$11^2))*(1)"
"=($B$10/(1-$B$11^2))*($B$11)"
"0"
"=($B$10/(1-$B$11^2))*($B$11)"
"=($B$10/(1-$B$11^2))*(1)"
"0"
"0"
"0"
"=($B$10/(1-$B$11^2))*((1-$B$11)/2)"
Range("B19").FormulaLocal
Range("B20").FormulaLocal
Range("B21").FormulaLocal
Range("C19").FormulaLocal
Range("C20").FormulaLocal
Range("C21").FormulaLocal
Range("D19").FormulaLocal
Range("D20").FormulaLocal
Range("D21").FormulaLocal
=
=
=
=
=
=
=
=
=
"=(($B$10*(1-$B$11))/((1+$B$11)*(1-2*$B$11)))*(1)"
"=(($B$10*(1-$B$11))/((1+$B$11)*(1-2*$B$11)))*(($B$11)/(1-$B$11))"
"0"
"=(($B$10*(1-$B$11))/((1+$B$11)*(1-2*$B$11)))*(($B$11)/(1-$B$11))"
"=(($B$10*(1-$B$11))/((1+$B$11)*(1-2*$B$11)))*(1)"
"0"
"0"
"0"
"=(($B$10*(1-$B$11))/((1+$B$11)*(1-2*$B$11)))*((1-2*$B$11)/(2-2*$B$11))"
Range("N2").Value = "Pesos de Gauss"
Range("N3").FormulaLocal = "=RAIZ(1/3)"
Range("N4").FormulaLocal = "=-RAIZ(1/3)"
Range("O3").Value = "1"
Range("O4").Value = "2"
Range("O5").Value = "3"
Range("O6").Value = "4"
Range("P2").Value = ChrW(951)
Range("Q2").Value = ChrW(958)
Range("P3").FormulaLocal
Range("Q3").FormulaLocal
Range("P4").FormulaLocal
Range("Q4").FormulaLocal
Range("P5").FormulaLocal
Range("Q5").FormulaLocal
Range("P6").FormulaLocal
Range("Q6").FormulaLocal
=
=
=
=
=
=
=
=
"=N3"
"=N3"
"=N3"
"=N4"
"=N4"
"=N3"
"=N4"
"=N4"
'Calculo de K1
Range("M9").Value = "Calculo de K1"
Range("M10").Value = "x"
Range("M11").Value = "y"
Range("M13").Value = "dxd" & ChrW(958)
Range("M14").Value = "dxd" & ChrW(951)
Range("M15").Value = "dyd" & ChrW(958)
Range("M16").Value = "dyd" & ChrW(951)
Range("M18").Value = "dN1d" & ChrW(958)
Range("M19").Value = "dN1d" & ChrW(951)
Range("M20").Value = "dN2d" & ChrW(958)
Range("M21").Value = "dN2d" & ChrW(951)
Range("M22").Value = "dN3d" & ChrW(958)
Range("M23").Value = "dN3d" & ChrW(951)
Range("M24").Value = "dN4d" & ChrW(958)
Range("M25").Value = "dN4d" & ChrW(951)
Range("M28").Value = "B"
Range("M32").Value = "B_trans"
Range("M41").Value = "B_trans*D*B"
Range("M50").Value = "K"
Range("P14").Value = "J1"
Range("P17").Value = "det(J1)"
Range("P19").Value = "inv(J1)"
Range("P22").Value = "derN"
Range("P25").Value = "inv(J1)*derN"
Range("R32").Value = "B_trans*D"
Range("N10").FormulaLocal
Range("N11").FormulaLocal
Range("N13").FormulaLocal
Range("N14").FormulaLocal
Range("N15").FormulaLocal
Range("N16").FormulaLocal
Range("N18").FormulaLocal
Range("N19").FormulaLocal
Range("N20").FormulaLocal
Range("N21").FormulaLocal
=
=
=
=
=
=
=
=
=
=
"x"
"y"
"dxd" & ChrW(958)
"dxd" & ChrW(951)
"dyd" & ChrW(958)
"dyd" & ChrW(951)
"dN1d" & ChrW(958)
"dN1d" & ChrW(951)
"dN2d" & ChrW(958)
"dN2d" & ChrW(951)
Range("N22").FormulaLocal = "dN3d" & ChrW(958)
Range("N23").FormulaLocal = "dN3d" & ChrW(951)
Range("N24").FormulaLocal = "dN4d" & ChrW(958)
Range("N25").FormulaLocal = "dN4d" & ChrW(951)
Range("N10").FormulaLocal = "=0,25*(1-$Q$3)*(1-$P$3)*$B$3+0,25*(1+$Q$3)*(1$P$3)*$B$4+0,25*(1+$Q$3)*(1+$P$3)*$B$5+0,25*(1-$Q$3)*(1+$P$3)*$B$6"
Range("N11").FormulaLocal = "=0,25*(1-$Q$3)*(1-$P$3)*$C$3+0,25*(1+$Q$3)*(1$P$3)*$C$4+0,25*(1+$Q$3)*(1+$P$3)*$C$5+0,25*(1-$Q$3)*(1+$P$3)*$C$6"
Range("N13").FormulaLocal = "=0,25*$B$3*(1+$P$3)-0,25*$B$4*(1+$P$3)-0,25*$B$5*(1-$P$3)+0,25*$B$6*(1-$P$3)"
Range("N14").FormulaLocal = "=0,25*$B$3*(1+$Q$3)+0,25*$B$4*(1-$Q$3)-0,25*$B$5*(1-$Q$3)-0,25*$B$6*(1+$Q$3)"
Range("N15").FormulaLocal = "=0,25*$C$3*(1+$P$3)-0,25*$C$4*(1+$P$3)-0,25*$C$5*(1-$P$3)+0,25*$C$6*(1-$P$3)"
Range("N16").FormulaLocal = "=0,25*$C$3*(1+$Q$3)+0,25*$C$4*(1-$Q$3)-0,25*$C$5*(1-$Q$3)-0,25*$C$6*(1+$Q$3)"
Range("N18").FormulaLocal
Range("N19").FormulaLocal
Range("N20").FormulaLocal
Range("N21").FormulaLocal
Range("N22").FormulaLocal
Range("N23").FormulaLocal
Range("N24").FormulaLocal
Range("N25").FormulaLocal
Range("Q14").FormulaLocal
Range("Q15").FormulaLocal
Range("R14").FormulaLocal
Range("R15").FormulaLocal
Range("Q17").FormulaLocal
Range("Q22").FormulaLocal
Range("Q23").FormulaLocal
Range("R22").FormulaLocal
Range("R23").FormulaLocal
Range("S22").FormulaLocal
Range("S23").FormulaLocal
Range("T22").FormulaLocal
Range("T23").FormulaLocal
Range("N28").FormulaLocal
Range("N29").FormulaLocal
Range("N30").FormulaLocal
Range("O28").FormulaLocal
Range("O29").FormulaLocal
Range("O30").FormulaLocal
Range("P28").FormulaLocal
Range("P29").FormulaLocal
Range("P30").FormulaLocal
Range("Q28").FormulaLocal
Range("Q29").FormulaLocal
Range("Q30").FormulaLocal
Range("R28").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
"=0,25+0,25*$P$3"
"=0,25+0,25*$Q$3"
"=-0,25-0,25*$P$3"
"=0,25-0,25*$Q$3"
"=-0,25+0,25*$P$3"
"=-0,25+0,25*$Q$3"
"=0,25-0,25*$P$3"
"=-0,25-0,25*$Q$3"
"=N13"
"=N14"
"=N15"
"=N16"
"=(Q14*R15)-(R14*Q15)"
"=N18"
"=N19"
"=N20"
"=N21"
"=N22"
"=N23"
"=N24"
"=N25"
"=Q25"
"0"
"=Q26"
"0"
"=Q26"
"=Q25"
"=R25"
"0"
"=R26"
"0"
"=R26"
"=R25"
"=S25"
Range("R29").FormulaLocal = "0"
Range("R30").FormulaLocal = "=S26"
Range("S28").FormulaLocal = "0"
Range("S29").FormulaLocal = "=S26"
Range("S30").FormulaLocal = "=S25"
Range("T28").FormulaLocal = "=T25"
Range("T29").FormulaLocal = "0"
Range("T30").FormulaLocal = "=T26"
Range("U28").FormulaLocal = "0"
Range("U29").FormulaLocal = "=T26"
Range("U30").FormulaLocal = "=T25"
Range("Q19:R20").Select
Selection.FormulaArray = "=MINVERSE(R[-5]C:R[-4]C[1])"
Range("Q25:T26").Select
Selection.FormulaArray = "=MMULT(R[-6]C[]:R[-5]C[1],R[-3]C[]:R[-2]C[3])"
Range("N32:P39").Select
Selection.FormulaArray = "=TRANSPOSE(R[-4]C[]:R[-2]C[7])"
Range("S32:U39").Select
Selection.FormulaArray = "=MMULT(R[]C[-5]:R[7]C[-3],R[-18]C[-17]:R[-16]C[-15])"
Range("N41:U48").Select
Selection.FormulaArray = "=MMULT(R[-9]C[5]:R[-2]C[7],R[-13]C[]:R[-11]C[7])"
Range("N50:U57").Select
Selection.FormulaArray = "=N41:U48*Q17*$B$7"
'Calculo de K2
Range("W9").Value = "Calculo de K2"
Range("W10").Value = "x"
Range("W11").Value = "y"
Range("W13").Value = "dxd" & ChrW(958)
Range("W14").Value = "dxd" & ChrW(951)
Range("W15").Value = "dyd" & ChrW(958)
Range("W16").Value = "dyd" & ChrW(951)
Range("W18").Value = "dN1d" & ChrW(958)
Range("W19").Value = "dN1d" & ChrW(951)
Range("W20").Value = "dN2d" & ChrW(958)
Range("W21").Value = "dN2d" & ChrW(951)
Range("W22").Value = "dN3d" & ChrW(958)
Range("W23").Value = "dN3d" & ChrW(951)
Range("W24").Value = "dN4d" & ChrW(958)
Range("W25").Value = "dN4d" & ChrW(951)
Range("W28").Value = "B"
Range("W32").Value = "B_trans"
Range("W41").Value = "B_trans*D*B"
Range("W50").Value = "K"
Range("Z14").Value = "J1"
Range("Z17").Value = "det(J1)"
Range("Z19").Value = "inv(J1)"
Range("Z22").Value = "derN"
Range("Z25").Value = "inv(J1)*derN"
Range("AB32").Value = "B_trans*D"
Range("X10").FormulaLocal = "=0,25*(1-$Q$4)*(1-$P$4)*$B$3+0,25*(1+$Q$4)*(1$P$4)*$B$4+0,25*(1+$Q$4)*(1+$P$4)*$B$5+0,25*(1-$Q$4)*(1+$P$4)*$B$6"
Range("X11").FormulaLocal = "=0,25*(1-$Q$4)*(1-$P$4)*$C$3+0,25*(1+$Q$4)*(1$P$4)*$C$4+0,25*(1+$Q$4)*(1+$P$4)*$C$5+0,25*(1-$Q$4)*(1+$P$4)*$C$6"
Range("X13").FormulaLocal = "=0,25*$B$3*(1+$P$4)-0,25*$B$4*(1+$P$4)-0,25*$B$5*(1-$P$4)+0,25*$B$6*(1-$P$4)"
Range("X14").FormulaLocal = "=0,25*$B$3*(1+$Q$4)+0,25*$B$4*(1-$Q$4)-0,25*$B$5*(1-$Q$4)-0,25*$B$6*(1+$Q$4)"
Range("X15").FormulaLocal = "=0,25*$C$3*(1+$P$4)-0,25*$C$4*(1+$P$4)-0,25*$C$5*(1-$P$4)+0,25*$C$6*(1-$P$4)"
Range("X16").FormulaLocal = "=0,25*$C$3*(1+$Q$4)+0,25*$C$4*(1-$Q$4)-0,25*$C$5*(1-$Q$4)-0,25*$C$6*(1+$Q$4)"
Range("X18").FormulaLocal = "=0,25+0,25*$P$4"
Range("X19").FormulaLocal = "=0,25+0,25*$Q$4"
Range("X20").FormulaLocal = "=-0,25-0,25*$P$4"
Range("X21").FormulaLocal = "=0,25-0,25*$Q$4"
Range("X22").FormulaLocal = "=-0,25+0,25*$P$4"
Range("X23").FormulaLocal = "=-0,25+0,25*$Q$4"
Range("X24").FormulaLocal = "=0,25-0,25*$P$4"
Range("X25").FormulaLocal = "=-0,25-0,25*$Q$4"
Range("AA14").FormulaLocal = "=X13"
Range("AA15").FormulaLocal = "=X14"
Range("AB14").FormulaLocal = "=X15"
Range("AB15").FormulaLocal = "=X16"
Range("AA17").FormulaLocal = "=(AA14*AB15)-(AB14*AA15)"
Range("AA22").FormulaLocal = "=X18"
Range("AA23").FormulaLocal = "=X19"
Range("AB22").FormulaLocal = "=X20"
Range("AB23").FormulaLocal = "=X21"
Range("AC22").FormulaLocal = "=X22"
Range("AC23").FormulaLocal = "=X23"
Range("AD22").FormulaLocal = "=X24"
Range("AD23").FormulaLocal = "=X25"
Range("X28").FormulaLocal = "=AA25"
Range("X29").FormulaLocal = "0"
Range("X30").FormulaLocal = "=AA26"
Range("Y28").FormulaLocal = "0"
Range("Y29").FormulaLocal = "=AA26"
Range("Y30").FormulaLocal = "=AA25"
Range("Z28").FormulaLocal = "=AB25"
Range("Z29").FormulaLocal = "0"
Range("Z30").FormulaLocal = "=AB26"
Range("AA28").FormulaLocal = "0"
Range("AA29").FormulaLocal = "=AB26"
Range("AA30").FormulaLocal = "=AB25"
Range("AB28").FormulaLocal = "=AC25"
Range("AB29").FormulaLocal = "0"
Range("AB30").FormulaLocal = "=AC26"
Range("AC28").FormulaLocal = "0"
Range("AC29").FormulaLocal = "=AC26"
Range("AC30").FormulaLocal = "=AC25"
Range("AD28").FormulaLocal = "=AD25"
Range("AD29").FormulaLocal = "0"
Range("AD30").FormulaLocal = "=AD26"
Range("AE28").FormulaLocal = "0"
Range("AE29").FormulaLocal = "=AD26"
Range("AE30").FormulaLocal = "=AD25"
Range("AA19:AB20").Select
Selection.FormulaArray = "=MINVERSE(R[-5]C:R[-4]C[1])"
Range("AA25:AD26").Select
Selection.FormulaArray = "=MMULT(R[-6]C[]:R[-5]C[1],R[-3]C[]:R[-2]C[3])"
Range("X32:Z39").Select
Selection.FormulaArray = "=TRANSPOSE(R[-4]C[]:R[-2]C[7])"
Range("AC32:AE39").Select
Selection.FormulaArray = "=MMULT(R[]C[-5]:R[7]C[-3],R[-18]C[-27]:R[-16]C[-25])"
Range("X41:AE48").Select
Selection.FormulaArray = "=MMULT(R[-9]C[5]:R[-2]C[7],R[-13]C[]:R[-11]C[7])"
Range("X50:AE57").Select
Selection.FormulaArray = "=X41:AE48*AA17*$B$7"
'Calculo de K3
Range("AG9").Value = "Calculo de K3"
Range("AG10").Value = "x"
Range("AG11").Value = "y"
Range("AG13").Value = "dxd" & ChrW(958)
Range("AG14").Value = "dxd" & ChrW(951)
Range("AG15").Value = "dyd" & ChrW(958)
Range("AG16").Value = "dyd" & ChrW(951)
Range("AG18").Value = "dN1d" & ChrW(958)
Range("AG19").Value = "dN1d" & ChrW(951)
Range("AG20").Value = "dN2d" & ChrW(958)
Range("AG21").Value = "dN2d" & ChrW(951)
Range("AG22").Value = "dN3d" & ChrW(958)
Range("AG23").Value = "dN3d" & ChrW(951)
Range("AG24").Value = "dN4d" & ChrW(958)
Range("AG25").Value = "dN4d" & ChrW(951)
Range("AG28").Value = "B"
Range("AG32").Value = "B_trans"
Range("AG41").Value = "B_trans*D*B"
Range("AG50").Value = "K"
Range("AJ14").Value = "J1"
Range("AJ17").Value = "det(J1)"
Range("AJ19").Value = "inv(J1)"
Range("AJ22").Value = "derN"
Range("AJ25").Value = "inv(J1)*derN"
Range("AL32").Value = "B_trans*D"
Range("AH10").FormulaLocal = "=0,25*(1-$Q$5)*(1-$P$5)*$B$3+0,25*(1+$Q$5)*(1$P$5)*$B$4+0,25*(1+$Q$5)*(1+$P$5)*$B$5+0,25*(1-$Q$5)*(1+$P$5)*$B$6"
Range("AH11").FormulaLocal = "=0,25*(1-$Q$5)*(1-$P$5)*$C$3+0,25*(1+$Q$5)*(1$P$5)*$C$4+0,25*(1+$Q$5)*(1+$P$5)*$C$5+0,25*(1-$Q$5)*(1+$P$5)*$C$6"
Range("AH13").FormulaLocal = "=0,25*$B$3*(1+$P$5)-0,25*$B$4*(1+$P$5)-0,25*$B$5*(1-$P$5)+0,25*$B$6*(1-$P$5)"
Range("AH14").FormulaLocal = "=0,25*$B$3*(1+$Q$5)+0,25*$B$4*(1-$Q$5)-0,25*$B$5*(1-$Q$5)-0,25*$B$6*(1+$Q$5)"
Range("AH15").FormulaLocal = "=0,25*$C$3*(1+$P$5)-0,25*$C$4*(1+$P$5)-0,25*$C$5*(1-$P$5)+0,25*$C$6*(1-$P$5)"
Range("AH16").FormulaLocal = "=0,25*$C$3*(1+$Q$5)+0,25*$C$4*(1-$Q$5)-0,25*$C$5*(1-$Q$5)-0,25*$C$6*(1+$Q$5)"
Range("AH18").FormulaLocal
Range("AH19").FormulaLocal
Range("AH20").FormulaLocal
Range("AH21").FormulaLocal
Range("AH22").FormulaLocal
Range("AH23").FormulaLocal
Range("AH24").FormulaLocal
Range("AH25").FormulaLocal
Range("AK14").FormulaLocal
Range("AK15").FormulaLocal
Range("AL14").FormulaLocal
Range("AL15").FormulaLocal
Range("AK17").FormulaLocal
Range("AK22").FormulaLocal
Range("AK23").FormulaLocal
Range("AL22").FormulaLocal
Range("AL23").FormulaLocal
Range("AM22").FormulaLocal
Range("AM23").FormulaLocal
Range("AN22").FormulaLocal
Range("AN23").FormulaLocal
Range("AH28").FormulaLocal
Range("AH29").FormulaLocal
Range("AH30").FormulaLocal
Range("AI28").FormulaLocal
Range("AI29").FormulaLocal
Range("AI30").FormulaLocal
Range("AJ28").FormulaLocal
Range("AJ29").FormulaLocal
Range("AJ30").FormulaLocal
Range("AK28").FormulaLocal
Range("AK29").FormulaLocal
Range("AK30").FormulaLocal
Range("AL28").FormulaLocal
Range("AL29").FormulaLocal
Range("AL30").FormulaLocal
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
"=0,25+0,25*$P$5"
"=0,25+0,25*$Q$5"
"=-0,25-0,25*$P$5"
"=0,25-0,25*$Q$5"
"=-0,25+0,25*$P$5"
"=-0,25+0,25*$Q$5"
"=0,25-0,25*$P$5"
"=-0,25-0,25*$Q$5"
"=AH13"
"=AH14"
"=AH15"
"=AH16"
"=(AK14*AL15)-(AL14*AK15)"
"=AH18"
"=AH19"
"=AH20"
"=AH21"
"=AH22"
"=AH23"
"=AH24"
"=AH25"
"=AK25"
"0"
"=AK26"
"0"
"=AK26"
"=AK25"
"=AL25"
"0"
"=AL26"
"0"
"=AL26"
"=AL25"
"=AM25"
"0"
"=AM26"
Range("AM28").FormulaLocal = "0"
Range("AM29").FormulaLocal = "=AM26"
Range("AM30").FormulaLocal = "=AM25"
Range("AN28").FormulaLocal = "=AN25"
Range("AN29").FormulaLocal = "0"
Range("AN30").FormulaLocal = "=AN26"
Range("AO28").FormulaLocal = "0"
Range("AO29").FormulaLocal = "=AN26"
Range("AO30").FormulaLocal = "=AN25"
Range("AK19:AL20").Select
Selection.FormulaArray = "=MINVERSE(R[-5]C:R[-4]C[1])"
Range("AK25:AN26").Select
Selection.FormulaArray = "=MMULT(R[-6]C[]:R[-5]C[1],R[-3]C[]:R[-2]C[3])"
Range("AH32:AJ39").Select
Selection.FormulaArray = "=TRANSPOSE(R[-4]C[]:R[-2]C[7])"
Range("AM32:AO39").Select
Selection.FormulaArray = "=MMULT(R[]C[-5]:R[7]C[-3],R[-18]C[-37]:R[-16]C[-35])"
Range("AH41:AO48").Select
Selection.FormulaArray = "=MMULT(R[-9]C[5]:R[-2]C[7],R[-13]C[]:R[-11]C[7])"
Range("AH50:AO57").Select
Selection.FormulaArray = "=AH41:AO48*AK17*$B$7"
'Calculo de K4
Range("AQ9").Value = "Calculo de K4"
Range("AQ10").Value = "x"
Range("AQ11").Value = "y"
Range("AQ13").Value = "dxd" & ChrW(958)
Range("AQ14").Value = "dxd" & ChrW(951)
Range("AQ15").Value = "dyd" & ChrW(958)
Range("AQ16").Value = "dyd" & ChrW(951)
Range("AQ18").Value = "dN1d" & ChrW(958)
Range("AQ19").Value = "dN1d" & ChrW(951)
Range("AQ20").Value = "dN2d" & ChrW(958)
Range("AQ21").Value = "dN2d" & ChrW(951)
Range("AQ22").Value = "dN3d" & ChrW(958)
Range("AQ23").Value = "dN3d" & ChrW(951)
Range("AQ24").Value = "dN4d" & ChrW(958)
Range("AQ25").Value = "dN4d" & ChrW(951)
Range("AQ28").Value = "B"
Range("AQ32").Value = "B_trans"
Range("AQ41").Value = "B_trans*D*B"
Range("AQ50").Value = "K"
Range("AT14").Value = "J1"
Range("AT17").Value = "det(J1)"
Range("AT19").Value = "inv(J1)"
Range("AT22").Value = "derN"
Range("AT25").Value = "inv(J1)*derN"
Range("AV32").Value = "B_trans*D"
Range("AR10").FormulaLocal = "=0,25*(1-$Q$6)*(1-$P$6)*$B$3+0,25*(1+$Q$6)*(1$P$6)*$B$4+0,25*(1+$Q$6)*(1+$P$6)*$B$5+0,25*(1-$Q$6)*(1+$P$6)*$B$6"
Range("AR11").FormulaLocal = "=0,25*(1-$Q$6)*(1-$P$6)*$C$3+0,25*(1+$Q$6)*(1$P$6)*$C$4+0,25*(1+$Q$6)*(1+$P$6)*$C$5+0,25*(1-$Q$6)*(1+$P$6)*$C$6"
Range("AR13").FormulaLocal = "=0,25*$B$3*(1+$P$6)-0,25*$B$4*(1+$P$6)-0,25*$B$5*(1-$P$6)+0,25*$B$6*(1-$P$6)"
Range("AR14").FormulaLocal = "=0,25*$B$3*(1+$Q$6)+0,25*$B$4*(1-$Q$6)-0,25*$B$5*(1-$Q$6)-0,25*$B$6*(1+$Q$6)"
Range("AR15").FormulaLocal = "=0,25*$C$3*(1+$P$6)-0,25*$C$4*(1+$P$6)-0,25*$C$5*(1-$P$6)+0,25*$C$6*(1-$P$6)"
Range("AR16").FormulaLocal = "=0,25*$C$3*(1+$Q$6)+0,25*$C$4*(1-$Q$6)-0,25*$C$5*(1-$Q$6)-0,25*$C$6*(1+$Q$6)"
Range("AR18").FormulaLocal = "=0,25+0,25*$P$6"
Range("AR19").FormulaLocal = "=0,25+0,25*$Q$6"
Range("AR20").FormulaLocal = "=-0,25-0,25*$P$6"
Range("AR21").FormulaLocal = "=0,25-0,25*$Q$6"
Range("AR22").FormulaLocal = "=-0,25+0,25*$P$6"
Range("AR23").FormulaLocal = "=-0,25+0,25*$Q$6"
Range("AR24").FormulaLocal = "=0,25-0,25*$P$6"
Range("AR25").FormulaLocal = "=-0,25-0,25*$Q$6"
Range("AU14").FormulaLocal = "=AR13"
Range("AU15").FormulaLocal = "=AR14"
Range("AV14").FormulaLocal = "=AR15"
Range("AV15").FormulaLocal = "=AR16"
Range("AU17").FormulaLocal = "=(AU14*AV15)-(AV14*AU15)"
Range("AU22").FormulaLocal = "=AR18"
Range("AU23").FormulaLocal = "=AR19"
Range("AV22").FormulaLocal = "=AR20"
Range("AV23").FormulaLocal = "=AR21"
Range("AW22").FormulaLocal = "=AR22"
Range("AW23").FormulaLocal = "=AR23"
Range("AX22").FormulaLocal = "=AR24"
Range("AX23").FormulaLocal = "=AR25"
Range("AR28").FormulaLocal = "=AU25"
Range("AR29").FormulaLocal = "0"
Range("AR30").FormulaLocal = "=AU26"
Range("AS28").FormulaLocal = "0"
Range("AS29").FormulaLocal = "=AU26"
Range("AS30").FormulaLocal = "=AU25"
Range("AT28").FormulaLocal = "=AV25"
Range("AT29").FormulaLocal = "0"
Range("AT30").FormulaLocal = "=AV26"
Range("AU28").FormulaLocal = "0"
Range("AU29").FormulaLocal = "=AV26"
Range("AU30").FormulaLocal = "=AV25"
Range("AV28").FormulaLocal = "=AW25"
Range("AV29").FormulaLocal = "0"
Range("AV30").FormulaLocal = "=AW26"
Range("AW28").FormulaLocal = "0"
Range("AW29").FormulaLocal = "=AW26"
Range("AW30").FormulaLocal = "=AW25"
Range("AX28").FormulaLocal = "=AX25"
Range("AX29").FormulaLocal = "0"
Range("AX30").FormulaLocal = "=AX26"
Range("AY28").FormulaLocal = "0"
Range("AY29").FormulaLocal = "=AX26"
Range("AY30").FormulaLocal = "=AX25"
Range("AU19:AV20").Select
Selection.FormulaArray = "=MINVERSE(R[-5]C:R[-4]C[1])"
Range("AU25:AX26").Select
Selection.FormulaArray = "=MMULT(R[-6]C[]:R[-5]C[1],R[-3]C[]:R[-2]C[3])"
Range("AR32:AT39").Select
Selection.FormulaArray = "=TRANSPOSE(R[-4]C[]:R[-2]C[7])"
Range("AW32:AY39").Select
Selection.FormulaArray = "=MMULT(R[]C[-5]:R[7]C[-3],R[-18]C[-47]:R[-16]C[-45])"
Range("AR41:AY48").Select
Selection.FormulaArray = "=MMULT(R[-9]C[5]:R[-2]C[7],R[-13]C[]:R[-11]C[7])"
Range("AR50:AY57").Select
Selection.FormulaArray = "=AR41:AY48*AU17*$B$7"
'Suma de todas
Range("B25:I32").Select
Selection.FormulaArray = "=N50:U57+X50:AE57+AH50:AO57+AR50:AY57"
Range("B24").FormulaLocal
Range("C24").FormulaLocal
Range("D24").FormulaLocal
Range("E24").FormulaLocal
Range("F24").FormulaLocal
Range("G24").FormulaLocal
Range("H24").FormulaLocal
Range("I24").FormulaLocal
=
=
=
=
=
=
=
=
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
&
&
&
&
&
&
&
&
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
&
&
&
&
&
&
&
&
"u"
"v"
"u"
"v"
"u"
"v"
"u"
"v"
&
&
&
&
&
&
&
&
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
&
&
&
&
&
&
&
&
";A3)"
";A3)"
";A4)"
";A4)"
";A5)"
";A5)"
";A6)"
";A6)"
Range("J25").FormulaLocal
Range("J26").FormulaLocal
Range("J27").FormulaLocal
Range("J28").FormulaLocal
Range("J29").FormulaLocal
Range("J30").FormulaLocal
Range("J31").FormulaLocal
Range("J32").FormulaLocal
Next i
End Function
=
=
=
=
=
=
=
=
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
"=CONCATENAR("
&
&
&
&
&
&
&
&
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
&
&
&
&
&
&
&
&
"u"
"v"
"u"
"v"
"u"
"v"
"u"
"v"
&
&
&
&
&
&
&
&
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
Chr(34)
&
&
&
&
&
&
&
&
";A3)"
";A3)"
";A4)"
";A4)"
";A5)"
";A5)"
";A6)"
";A6)"
function varargout = FEM_Rafa2(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @FEM_Rafa2_OpeningFcn, ...
'gui_OutputFcn', @FEM_Rafa2_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',
[]);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function FEM_Rafa2_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = FEM_Rafa2_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function pushbutton2_Callback(hObject, eventdata, handles)
ruta=get(handles.edit6,'String');
archivo=get(handles.edit5,'String');
if archivo==0
return;
else
% abrir archivo para leerlo
fid =fopen([ruta archivo],'r');
if fid==-1
error(sprintf('El archivo no pudo abrirse para lectura.'))
end
% mientras no llegue al final del archivo seguirá leyendo
Lineas={ }; % cell array que contendrá las líneas
Nodos={ }; % cell array que contendrá los nodos
Elementos={ }; % cell array que contendrá los elementos
Grupos={ }; % cell array que contendrá los grupos
Apoyos={ }; % cell array que contendrá los apoyos
Cargas={ }; % cell array que contendrá las cargas
def_nodos=0;
def_elementos=0;
def_material=0;
def_espesor=0;
def_grupo=0;
def_cargas=0;
def_apoyo=0;
while ~feof(fid)
linea = fgetl(fid); % lee toda la línea
Lineas{end+1,1}=linea;
if strcmp(linea,'*Node')==1 %empieza la definicion de nodos, es el 1º nodo
def_nodos=1;
end
if length(linea)>7
if strcmp(linea(1:8),'*Element')==1 %termina la definicion de nodos, es el 1º nodo
def_nodos=0;
def_elementos=1;
end
if strcmp(linea(1:5),'*Nset')==1 %termina la definicion de elementos, empiezan los grupos
def_elementos=0;
end
end
if length(linea)>7
if def_nodos==1 %esta definiendo un nodo
%nº de nodo
Nodos{end+1,1}=strtrim(linea(1:7));
%coord.X
Nodos{end,2}=strtrim(linea(9:21));
%coord.Y
Nodos{end,3}=strtrim(linea(23:35));
end
if and(def_elementos==1,strcmp(linea(1:8),'*Element')==0) %esta definiendo un elemento
x=strfind(linea,',');
%nº de elemento
Elementos{end+1,1}=strtrim(linea(1:(x(1)-1)));
%nodo nº1
Elementos{end,2}=strtrim(linea((x(1)+1):(x(2)-1)));
%nodo nº2
Elementos{end,3}=strtrim(linea((x(2)+1):(x(3)-1)));
if length(linea)>19
%nodo nº3
Elementos{end,4}=strtrim(linea((x(3)+1):(x(4)-1)));
%nodo nº4 -->si es elemento rectangular
Elementos{end,5}=strtrim(linea((x(4)+1):length(linea)));
else
%nodo nº3
Elementos{end,4}=strtrim(linea((x(3)+1):length(linea)));
end
end
if def_material==1
x=strfind(linea,',');
E=strtrim(linea(1:(x-1)));
v=strtrim(linea((x+1):length(linea)));
def_material=0;
end
if strcmp(linea(1:8),'*Elastic')==1 %esta definiendo el material
def_material=1;
end
end
if def_espesor==1
x=strfind(linea,',');
espesor=strtrim(linea(1:(x-1)));
def_espesor=0;
end
if def_grupo==1
def_grupo=0;
%nº de grupo
Grupos{end+1,1}=strtrim(STR);
%nodos
Grupos{end,2}=strtrim(linea);
end
if length(linea)>16
if and(def_apoyo==1,strcmp(linea(1:10), '_PickedSet')==1)==1 %Empieza la definicion de un apoyo
def_apoyo=0;
x=strfind(linea,',');
x=x-1;
STR=linea(1:x);
STR =linea(11:length(STR));
[m,n] = size(Apoyos);
%vemos que apoyo esta definiendo
STR2=linea((length(linea)-1):length(linea));
%debemos buscar en q linea esta el grupo
[n_grupos,col]=size(Grupos);
for lin=1:n_grupos
if strcmp(Grupos(lin,1),STR)==1;
break
end
end
cadena=Grupos(lin,2);
string=(cadena{1});
C=strread(string,'%s','delimiter',',');
[m2,n] = size(C);
if m==0 %aun no hay ningun apoyo definido
for apo=1:m2
Apoyos(end+1,1)=C(apo);
col=str2num(STR2)+1;
Apoyos(end,col)=num2cell(0);
end
else
existe=0;
for apo=1:m2
%debemos ver si ya existe ese apoyo
for exis=1:m
col=C(apo);
col1=col{1};
col2=str2num(col1);
col=Apoyos(exis,1);
col1=col{1};
col3=str2num(col1);
if col2==col3
existe=1;
break
end
end
if existe==1
col=str2num(STR2)+1;
Apoyos(exis,col)=num2cell(0);
else
Apoyos(end+1,1)=C(apo);
col=str2num(STR2)+1;
Apoyos(end,col)=num2cell(0);
end
end
end
end
end
if length(linea)>16
if and(def_cargas==1,strcmp(linea(1:10), '_PickedSet')==1)==1 %Empieza la definicion de una carga
def_cargas=0;
x=strfind(linea,',');
x=x-1;
STR=linea(1:x);
%este es el grupo donde se define la carga
STR =linea(11:length(STR));
[m,n] = size(Cargas);
%vemos en que sentido está la carga
x=strfind(linea,',');
SENTIDO=linea((x(1)+1):(x(2)-1));
VALOR=linea((x(2)+1):length(linea));
%debemos buscar en q linea esta el grupo
[n_grupos,col]=size(Grupos);
for lin=1:n_grupos
if strcmp(Grupos(lin,1),STR)==1;
break
end
end
cadena=Grupos(lin,2);
string=(cadena{1});
C=strread(string,'%s','delimiter',',');
[m2,n] = size(C);
for carg=1:m2
col=C(carg);
col2=col{1};
col3=str2num(col2);
%nodo
Cargas(end+1,1)=num2cell(col3);
%sentido
col3=str2num(SENTIDO);
Cargas(end,2)=num2cell(col3);
%valor
col3=str2num(VALOR);
Cargas(end,3)=num2cell(col3);
end
end
end
if length(linea)>13
if strcmp(linea(1:14),'*Solid Section')==1 %esta definiendo el espesor
def_espesor=1;
end
end
if length(linea)>21
if strcmp(linea(1:22), '*Nset, nset=_PickedSet')==1 %Empieza la definicion de un grupo
def_grupo=1;
x=strfind(linea,', internal');
x=x-1;
STR=linea(1:x);
STR =linea(23:length(STR));
end
end
if length(linea)>8
if strcmp(linea(1:9), '*Boundary')==1 %Empieza la definicion de un apoyo
def_apoyo=1;
end
end
if length(linea)>13
if strcmp(linea(1:14), '** Name: Load-')==1 %Empieza la definicion de una carga
def_cargas=1;
end
end
end
end
fclose(fid); % cierra el archivo leído
%Una vez leidos los nodos, los elementos,el material, el espesor,
%las cargas y las condiciones de contorno..calculamos la K de cada elemento
[filas,columnas] = size(Elementos);
if columnas==5 %estamos hablando de elementos de 4 nodos
%creamos un array que contenga todos los K de elementos de todos los
%elementos
n_filas=8;
K_elementos = zeros(filas,8,8);
B_elementos = zeros(filas,8,8);
for elem = 1:filas
for nod=1:4
aux=nod+1;
aux=cellstr(Elementos(elem,aux));
aux2=aux{1};
coord_x_cell(1,nod)=cellstr(Nodos(str2num(aux2),2));
coord_y_cell(1,nod)=cellstr(Nodos(str2num(aux2),3));
end
coord_x=cellfun(@str2num,coord_x_cell);
coord_y=cellfun(@str2num,coord_y_cell);
B_aux=zeros(3,8);
for nod=1:4
b_aux2=calcular_B_rect(nod,coord_x,coord_y);
for fila=1:3
for column=1:8
B_4nodos(elem,nod,fila,column)=b_aux2(fila,column);
end
end
B_aux=B_aux+b_aux2;
end
k_aux=calcular_K_rect(coord_x,coord_y,E,v,espesor);
for fila=1:8
for column=1:8
K_elementos(elem,fila,column)=k_aux(fila,column);
end
end
for fila=1:3
for column=1:8
B_elementos(elem,fila,column)=B_aux(fila,column);
end
end
end
elseif columnas==4 %tenemos elementos de 3 nodos
%creamos un array que contenga todos los K de elementos de todos los
%elementos
n_filas=6;
K_elementos = zeros(filas,6,6);
B_elementos = zeros(filas,6,6);
for elem = 1:filas
for nod=1:3
aux=nod+1;
aux=cellstr(Elementos(elem,aux));
aux2=aux{1};
coord_x_cell(1,nod)=cellstr(Nodos(str2num(aux2),2));
coord_y_cell(1,nod)=cellstr(Nodos(str2num(aux2),3));
end
coord_x=cellfun(@str2num,coord_x_cell);
coord_y=cellfun(@str2num,coord_y_cell);
coor_nodo1(1)=coord_x(1,1);
coor_nodo1(2)=coord_y(1,1);
coor_nodo2(1)=coord_x(1,2);
coor_nodo2(2)=coord_y(1,2);
coor_nodo3(1)=coord_x(1,3);
coor_nodo3(2)=coord_y(1,3);
Ar=abs(Area(coor_nodo1,coor_nodo2,coor_nodo3));
k_aux=calcular_K_triang(Ar,coor_nodo1,coor_nodo2,coor_nodo3,E,v,espesor);
B_aux=calcular_B_triang(Ar,coor_nodo1,coor_nodo2,coor_nodo3);
for fila=1:6
for column=1:6
K_elementos(elem,fila,column)=k_aux(fila,column);
end
end
for fila=1:3
for column=1:6
B_elementos(elem,fila,column)=B_aux(fila,column);
end
end
end
end
%Una vez tenemos todas las matrices de rigidez de cada uno de los elementos
%debemos ensamblar la matriz global de rigidez
[n_nodos,borra] = size(Nodos);
K_global=zeros(2*n_nodos,2*n_nodos);
for elem=1:filas
%En cada elemento, vemos que nodos tiene el elemento en cuestion
aux=1+1; %nº de nodo+1
aux=cellstr(Elementos(elem,aux)); %nos dice que nodo es
aux2=aux{1};%nos dice que nodo es
nodo1 = str2num(aux2);
aux=2+1; %nº de nodo+1
aux=cellstr(Elementos(elem,aux)); %nos dice que nodo es
aux2=aux{1};%nos dice que nodo es
nodo2 = str2num(aux2);
aux=3+1; %nº de nodo+1
aux=cellstr(Elementos(elem,aux)); %nos dice que nodo es
aux2=aux{1};%nos dice que nodo es
nodo3 = str2num(aux2);
if n_filas==8
aux=4+1; %nº de nodo+1
aux=cellstr(Elementos(elem,aux)); %nos dice que nodo es
aux2=aux{1};%nos dice que nodo es
nodo4 = str2num(aux2);
end
%Actuamos sobre la fila x del nodo 1
fila = 2 * nodo1 - 1 ;
%Actuamos en las 8 columnas que tocan en esta fila
%Columna 1
columna = 2 * nodo1 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,1,1);
%Columna 2
columna = 2 * nodo1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,1,2);
%Columna 3
columna = 2 * nodo2 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,1,3);
%Columna 4
columna = 2 * nodo2 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,1,4);
%Columna 5
columna = 2 * nodo3 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,1,5);
%Columna 6
columna = 2 * nodo3 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,1,6);
if n_filas==8
%Columna 7
columna = 2 * nodo4 - 1;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,1,7);
%Columna 8
columna = 2 * nodo4 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,1,8);
end
%Actuamos sobre la fila y del nodo 1
fila = 2 * nodo1;
%Actuamos en las 6 columnas que tocan en esta fila
%Columna 1
columna = 2 * nodo1 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,2,1);
%Columna 2
columna = 2 * nodo1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,2,2);
%Columna 3
columna = 2 * nodo2 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,2,3);
%Columna 4
columna = 2 * nodo2 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,2,4);
%Columna 5
columna = 2 * nodo3 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,2,5);
%Columna 6
columna = 2 * nodo3 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,2,6);
if n_filas==8
%Columna 7
columna = 2 * nodo4 - 1;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,2,7);
%Columna 8
columna = 2 * nodo4 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,2,8);
end
%Actuamos sobre la fila x del nodo 2
fila = 2 * nodo2 - 1 ;
%Actuamos en las 8 columnas que tocan en esta fila
%Columna 1
columna = 2 * nodo1 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,3,1);
%Columna 2
columna = 2 * nodo1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,3,2);
%Columna 3
columna = 2 * nodo2 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,3,3);
%Columna 4
columna = 2 * nodo2 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,3,4);
%Columna 5
columna = 2 * nodo3 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,3,5);
%Columna 6
columna = 2 * nodo3 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,3,6);
if n_filas==8
%Columna 7
columna = 2 * nodo4 - 1;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,3,7);
%Columna 8
columna = 2 * nodo4 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,3,8);
end
%Actuamos sobre la fila y del nodo 2
fila = 2 * nodo2 ;
%Actuamos en las 8 columnas que tocan en esta fila
%Columna 1
columna = 2 * nodo1 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,4,1);
%Columna 2
columna = 2 * nodo1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,4,2);
%Columna 3
columna = 2 * nodo2 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,4,3);
%Columna 4
columna = 2 * nodo2;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,4,4);
%Columna 5
columna = 2 * nodo3 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,4,5);
%Columna 6
columna = 2 * nodo3;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,4,6);
if n_filas==8
%Columna 7
columna = 2 * nodo4 - 1;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,4,7);
%Columna 8
columna = 2 * nodo4 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,4,8);
end
%Actuamos sobre la fila x del nodo 3
fila = 2 * nodo3 - 1 ;
%Actuamos en las 8 columnas que tocan en esta fila
%Columna 1
columna = 2 * nodo1 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,5,1);
%Columna 2
columna = 2 * nodo1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,5,2);
%Columna 3
columna = 2 * nodo2 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,5,3);
%Columna 4
columna = 2 * nodo2;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,5,4);
%Columna 5
columna = 2 * nodo3 - 1;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,5,5);
%Columna 6
columna = 2 * nodo3 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,5,6);
if n_filas==8
%Columna 7
columna = 2 * nodo4 - 1;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,5,7);
%Columna 8
columna = 2 * nodo4 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,5,8);
end
%Actuamos sobre la fila y del nodo 3
fila = 2 * nodo3 ;
%Actuamos en las 8 columnas que tocan en esta fila
%Columna 1
columna = 2 * nodo1 - 1;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,6,1);
%Columna 2
columna = 2 * nodo1;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,6,2);
%Columna 3
columna = 2 * nodo2 - 1;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,6,3);
%Columna 4
columna = 2 * nodo2 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,6,4);
%Columna 5
columna = 2 * nodo3 - 1;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,6,5);
%Columna 6
columna = 2 * nodo3;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,6,6);
if n_filas==8
%Columna 7
columna = 2 * nodo4 - 1;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,6,7);
%Columna 8
columna = 2 * nodo4 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,6,8);
end
if n_filas==8
%Actuamos sobre la fila x del nodo 4
fila = 2 * nodo4 - 1;
%Actuamos en las 8 columnas que tocan en esta fila
%Columna 1
columna = 2 * nodo1 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,7,1);
%Columna 2
columna = 2 * nodo1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,7,2);
%Columna 3
columna = 2 * nodo2 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,7,3);
%Columna 4
columna = 2 * nodo2 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,7,4);
%Columna 5
columna = 2 * nodo3 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,7,5);
%Columna 6
columna = 2 * nodo3 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,7,6);
if n_filas==8
%Columna 7
columna = 2 * nodo4 - 1;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,7,7);
%Columna 8
columna = 2 * nodo4 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,7,8);
end
%Actuamos sobre la fila y del nodo 4
fila = 2 * nodo4;
%Actuamos en las 8 columnas que tocan en esta fila
%Columna 1
columna = 2 * nodo1 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,8,1);
%Columna 2
columna = 2 * nodo1;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,8,2);
%Columna 3
columna = 2 * nodo2 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,8,3);
%Columna 4
columna = 2 * nodo2 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,8,4);
%Columna 5
columna = 2 * nodo3 - 1 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,8,5);
%Columna 6
columna = 2 * nodo3 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,8,6);
if n_filas==8
%Columna 7
columna = 2 * nodo4 - 1;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,8,7);
%Columna 8
columna = 2 * nodo4 ;
rig = K_global(fila, columna);
K_global(fila, columna) = rig + K_elementos(elem,8,8);
end
end
end
%Ahora debemos ensamblar las cargas en el vector de fuerzas
%Por cada carga, calcula la fila que debemos implementar
[m,n]=size(Cargas);
F=zeros(2*n_nodos,1);
for carg=1:m
col=Cargas(carg,1);
col2=col{1};
fil=2*col2;
col=Cargas(carg,2);
col2=col{1};
if col2==1
fil=fil-1;
end
col=Cargas(carg,3);
col2=col{1};
F(fil,1)=F(fil,1)+col2;
end
%-----YA ESTA ENSAMBLADA TODA LA MATRIZ DE RIGIDEZ------------------------%Calculamos ahora la matriz reducida
filas_borrar={ }; % cell array que contendrá las filas a eliminar
[m,n]=size(Apoyos);
for apo=1:m
nod=Apoyos(apo,1);
nudo=nod{1};
col=Apoyos(apo,2);
colX=col{1};
col=Apoyos(apo,3);
colY=col{1};
if colX==0
fil=2*str2num(nudo)-1;
filas_borrar(end+1,1)=num2cell(fil);
end
if colY==0
fil=2*str2num(nudo);
filas_borrar(end+1,1)=num2cell(fil);
end
end
%los convierto en numeros
[m,n]=size(filas_borrar);
for i=1:m
col= filas_borrar(i,1);
col1=col{1};
borra(i,1)=col1;
end
borra2=borra';
%ordeno el vector de mayor a menor
borra=sort(borra2);
borra=fliplr(borra);
borra=borra';
%borro las filas y columnas de la matriz global y de la de cargas
K_red=K_global;
for i=1:m
fil_col= borra(i,1);
K_red(fil_col,:)=[ ];
K_red(:,fil_col)=[ ];
F(fil_col,:)=[ ];
end
%calculo la inversa
K_red_inv=inv(K_red);
%Calculo la matriz de desplazamientos desconocidos
U=K_red_inv*F;
%copiamos la matriz de desplazamientos
U_tot=U;
%insertamos en la matriz de desplazamientos las filas antes borradas
borra=sort(borra);
for i=1:m
[f,c]=size(U_tot);
fil_col= borra(i,1);
U_tot=[U_tot(1:fil_col-1,:);
0;
U_tot(fil_col:f,:)];
end
%calculamos la matriz de desplazamientos
desplz=zeros(n_nodos,3);
for i=1:n_nodos
%nº de nodo
desplz(i,1)=i;
%despl_x
fil=2*i-1;
desplz(i,2)=U_tot(fil,1);
%despl_y
fil=2*i;
desplz(i,3)=U_tot(fil,1);
end
%Rellenamos las tablas con las coordenadas iniciales de los nodos
t=handles.uitable1;
set(t,'Data',Nodos);
t=handles.uitable2;
set(t,'Data',Elementos);
t=handles.uitable3;
set(t,'Data',desplz);
%Calculamos las tensiones en cada elemento
if n_filas==8
S_comp=zeros(filas*4,8);
elseif n_filas==6
S_comp=zeros(filas*3,8);
end
U_aux=zeros(2*n_filas,1);
s_aux2=zeros(2,2);
%Tension plana
d11=str2num(E)/(1-str2num(v).^2);
d12=(str2num(E)/(1-str2num(v).^2))*(str2num(v));
d13=0;
d21=(str2num(E)/(1-str2num(v).^2))*(str2num(v));
d22=(str2num(E)/(1-str2num(v).^2));
d23=0;
d31=0;
d32=0;
d33=(str2num(E)/(1-str2num(v).^2))*((1-str2num(v))/2);
D=[d11 d12 d13 ;...
d21 d22 d23 ;...
d31 d32 d33];
for elem=1:filas
%vemos cuales son los nodos que componen el elemento
%En cada elemento, vemos que nodos tiene el elemento en cuestion
aux=1+1; %nº de nodo+1
aux=cellstr(Elementos(elem,aux)); %nos dice que nodo es
aux2=aux{1};%nos dice que nodo es
nodo1 = str2num(aux2);
aux=2+1; %nº de nodo+1
aux=cellstr(Elementos(elem,aux)); %nos dice que nodo es
aux2=aux{1};%nos dice que nodo es
nodo2 = str2num(aux2);
aux=3+1; %nº de nodo+1
aux=cellstr(Elementos(elem,aux)); %nos dice que nodo es
aux2=aux{1};%nos dice que nodo es
nodo3 = str2num(aux2);
%rellenamos el vector auxliar de desplazamientos
clear U_aux;
fil=2*nodo1-1;
U_aux(1,1)=U_tot(fil,1);
fil=2*nodo1;
U_aux(2,1)=U_tot(fil,1);
fil=2*nodo2-1;
U_aux(3,1)=U_tot(fil,1);
fil=2*nodo2;
U_aux(4,1)=U_tot(fil,1);
fil=2*nodo3-1;
U_aux(5,1)=U_tot(fil,1);
fil=2*nodo3;
U_aux(6,1)=U_tot(fil,1);
if n_filas==8
aux=4+1; %nº de nodo+1
aux=cellstr(Elementos(elem,aux)); %nos dice que nodo es
aux2=aux{1};%nos dice que nodo es
nodo4 = str2num(aux2);
%rellenamos el vector auxliar de desplazamientos
fil=2*nodo4-1;
U_aux(7,1)=U_tot(fil,1);
fil=2*nodo4;
U_aux(8,1)=U_tot(fil,1);
end
if n_filas==8 %Tensiones diferentes el elemento, ya que existen 4 pto de integración o de Gauss
for i=1:3
for j=1:n_filas
B_aux1(i,j)=B_4nodos(elem,1,i,j);
B_aux2(i,j)=B_4nodos(elem,2,i,j);
B_aux3(i,j)=B_4nodos(elem,3,i,j);
B_aux4(i,j)=B_4nodos(elem,4,i,j);
end
end
for i=1:3
%Tensiones y deformaciones en ptos de integracion
s_aux_gauss1=D*B_aux1*U_aux;
s_aux_gauss2=D*B_aux2*U_aux;
s_aux_gauss3=D*B_aux3*U_aux;
s_aux_gauss4=D*B_aux4*U_aux;
e_aux_gauss1=inv(D)*s_aux_gauss1;
e_aux_gauss2=inv(D)*s_aux_gauss2;
e_aux_gauss3=inv(D)*s_aux_gauss3;
e_aux_gauss4=inv(D)*s_aux_gauss4;
%Ya tenemos calculadas las componentes tensiones en cada PTO DE INTEGRACION de cada elemento
%Tensiones y deformaciones en nodos mediante extrapolacion
a=1/sqrt(1/3);
b=1/sqrt(1/3);
N1_nodo1=0.25*((1+a)*(1+b));
N2_nodo1=0.25*((1+a)*(1-b));
N3_nodo1=0.25*((1-a)*(1+b));
N4_nodo1=0.25*((1-a)*(1-b));
a=1/sqrt(1/3);
b=-1/sqrt(1/3);
N1_nodo2=0.25*((1+a)*(1+b));
N2_nodo2=0.25*((1+a)*(1-b));
N3_nodo2=0.25*((1-a)*(1+b));
N4_nodo2=0.25*((1-a)*(1-b));
a=-1/sqrt(1/3);
b=-1/sqrt(1/3);
N1_nodo3=0.25*((1+a)*(1+b));
N2_nodo3=0.25*((1+a)*(1-b));
N3_nodo3=0.25*((1-a)*(1+b));
N4_nodo3=0.25*((1-a)*(1-b));
a=-1/sqrt(1/3);
b=1/sqrt(1/3);
N1_nodo4=0.25*((1+a)*(1+b));
N2_nodo4=0.25*((1+a)*(1-b));
N3_nodo4=0.25*((1-a)*(1+b));
N4_nodo4=0.25*((1-a)*(1-b));
s_aux1(1,1)=N1_nodo1*s_aux_gauss1(1,1)+N2_nodo1*s_aux_gauss2(1,1)+N3_nodo1*s_aux_gauss3(1,1)+N4_nodo1*s_aux_gauss4(1,1);
s_aux1(2,2)=N1_nodo1*s_aux_gauss1(2,1)+N2_nodo1*s_aux_gauss2(2,1)+N3_nodo1*s_aux_gauss3(2,1)+N4_nodo1*s_aux_gauss4(2,1);
s_aux1(1,2)=N1_nodo1*s_aux_gauss1(3,1)+N2_nodo1*s_aux_gauss2(3,1)+N3_nodo1*s_aux_gauss3(3,1)+N4_nodo1*s_aux_gauss4(3,1);
s_aux1(2,1)=s_aux1(1,2);
s_aux2(1,1)=N1_nodo2*s_aux_gauss1(1,1)+N2_nodo2*s_aux_gauss2(1,1)+N3_nodo2*s_aux_gauss3(1,1)+N4_nodo2*s_aux_gauss4(1,1);
s_aux2(2,2)=N1_nodo2*s_aux_gauss1(2,1)+N2_nodo2*s_aux_gauss2(2,1)+N3_nodo2*s_aux_gauss3(2,1)+N4_nodo2*s_aux_gauss4(2,1);
s_aux2(1,2)=N1_nodo2*s_aux_gauss1(3,1)+N2_nodo2*s_aux_gauss2(3,1)+N3_nodo2*s_aux_gauss3(3,1)+N4_nodo2*s_aux_gauss4(3,1);
s_aux2(2,1)=s_aux2(1,2);
s_aux3(1,1)=N1_nodo3*s_aux_gauss1(1,1)+N2_nodo3*s_aux_gauss2(1,1)+N3_nodo3*s_aux_gauss3(1,1)+N4_nodo3*s_aux_gauss4(1,1);
s_aux3(2,2)=N1_nodo3*s_aux_gauss1(2,1)+N2_nodo3*s_aux_gauss2(2,1)+N3_nodo3*s_aux_gauss3(2,1)+N4_nodo3*s_aux_gauss4(2,1);
s_aux3(1,2)=N1_nodo3*s_aux_gauss1(3,1)+N2_nodo3*s_aux_gauss2(3,1)+N3_nodo3*s_aux_gauss3(3,1)+N4_nodo3*s_aux_gauss4(3,1);
s_aux3(2,1)=s_aux3(1,2);
s_aux4(1,1)=N1_nodo4*s_aux_gauss1(1,1)+N2_nodo4*s_aux_gauss2(1,1)+N3_nodo4*s_aux_gauss3(1,1)+N4_nodo4*s_aux_gauss4(1,1);
s_aux4(2,2)=N1_nodo4*s_aux_gauss1(2,1)+N2_nodo4*s_aux_gauss2(2,1)+N3_nodo4*s_aux_gauss3(2,1)+N4_nodo4*s_aux_gauss4(2,1);
s_aux4(1,2)=N1_nodo4*s_aux_gauss1(3,1)+N2_nodo4*s_aux_gauss2(3,1)+N3_nodo4*s_aux_gauss3(3,1)+N4_nodo4*s_aux_gauss4(3,1);
s_aux4(2,1)=s_aux4(1,2);
e_aux1(1,1)=N1_nodo1*e_aux_gauss1(1,1)+N2_nodo1*e_aux_gauss2(1,1)+N3_nodo1*e_aux_gauss3(1,1)+N4_nodo1*e_aux_gauss4(1,1);
e_aux1(2,2)=N1_nodo1*e_aux_gauss1(2,1)+N2_nodo1*e_aux_gauss2(2,1)+N3_nodo1*e_aux_gauss3(2,1)+N4_nodo1*e_aux_gauss4(2,1);
e_aux1(1,2)=N1_nodo1*e_aux_gauss1(3,1)+N2_nodo1*e_aux_gauss2(3,1)+N3_nodo1*e_aux_gauss3(3,1)+N4_nodo1*e_aux_gauss4(3,1);
e_aux1(2,1)=e_aux1(1,2);
e_aux2(1,1)=N1_nodo2*e_aux_gauss1(1,1)+N2_nodo2*e_aux_gauss2(1,1)+N3_nodo2*e_aux_gauss3(1,1)+N4_nodo2*e_aux_gauss4(1,1);
e_aux2(2,2)=N1_nodo2*e_aux_gauss1(2,1)+N2_nodo2*e_aux_gauss2(2,1)+N3_nodo2*e_aux_gauss3(2,1)+N4_nodo2*e_aux_gauss4(2,1);
e_aux2(1,2)=N1_nodo2*e_aux_gauss1(3,1)+N2_nodo2*e_aux_gauss2(3,1)+N3_nodo2*e_aux_gauss3(3,1)+N4_nodo2*e_aux_gauss4(3,1);
e_aux2(2,1)=e_aux2(1,2);
e_aux3(1,1)=N1_nodo3*e_aux_gauss1(1,1)+N2_nodo3*e_aux_gauss2(1,1)+N3_nodo3*e_aux_gauss3(1,1)+N4_nodo3*e_aux_gauss4(1,1);
e_aux3(2,2)=N1_nodo3*e_aux_gauss1(2,1)+N2_nodo3*e_aux_gauss2(2,1)+N3_nodo3*e_aux_gauss3(2,1)+N4_nodo3*e_aux_gauss4(2,1);
e_aux3(1,2)=N1_nodo3*e_aux_gauss1(3,1)+N2_nodo3*e_aux_gauss2(3,1)+N3_nodo3*e_aux_gauss3(3,1)+N4_nodo3*e_aux_gauss4(3,1);
e_aux3(2,1)=e_aux3(1,2);
e_aux4(1,1)=N1_nodo4*e_aux_gauss1(1,1)+N2_nodo4*e_aux_gauss2(1,1)+N3_nodo4*e_aux_gauss3(1,1)+N4_nodo4*e_aux_gauss4(1,1);
e_aux4(2,2)=N1_nodo4*e_aux_gauss1(2,1)+N2_nodo4*e_aux_gauss2(2,1)+N3_nodo4*e_aux_gauss3(2,1)+N4_nodo4*e_aux_gauss4(2,1);
e_aux4(1,2)=N1_nodo4*e_aux_gauss1(3,1)+N2_nodo4*e_aux_gauss2(3,1)+N3_nodo4*e_aux_gauss3(3,1)+N4_nodo4*e_aux_gauss4(3,1);
e_aux4(2,1)=e_aux4(1,2);
%Construimos una matriz de tensiones por cada elemento en el que las filas
%sean los nodos(3 o 4 filas, segun el elemento) y las columnas sean:
%||
|
|
|
|
|
|
|
|
|
|
|
|
|
%||Elemento|Nodo|S11|S22|S12|S_Max.Ppal|S_Min.PPal|V.Mises|e11|e22|e12|e_Max.Ppal|e_Min.PPal|
%||
|
|
|
|
|
|
|
|
|
|
|
|
|
S_princ1=eig(s_aux1);
S_princ2=eig(s_aux2);
S_princ3=eig(s_aux3);
S_princ4=eig(s_aux4);
s_max1=max(S_princ1);
s_min1=min(S_princ1);
s_vm1=((s_max1)^2+(s_min1)^2-(s_max1*s_min1))^(0.5);
s_max2=max(S_princ2);
s_min2=min(S_princ2);
s_vm2=((s_max2)^2+(s_min2)^2-(s_max2*s_min2))^(0.5);
s_max3=max(S_princ3);
s_min3=min(S_princ3);
s_vm3=((s_max3)^2+(s_min3)^2-(s_max3*s_min3))^(0.5);
s_max4=max(S_princ4);
s_min4=min(S_princ4);
s_vm4=((s_max4)^2+(s_min4)^2-(s_max4*s_min4))^(0.5);
if s_max1<0
s_max1=0;
end
if s_min1>0
s_min1=0;
end
if s_max2<0
s_max2=0;
end
if s_min2>0
s_min2=0;
end
if s_max3<0
s_max3=0;
end
if s_min3>0
s_min3=0;
end
if s_max4<0
s_max4=0;
end
if s_min4>0
s_min4=0;
end
S_comp(4*elem-3,1)=elem;
S_comp(4*elem-3,2)=nodo1;
S_comp(4*elem-3,3)=s_aux1(1,1); %S11;
S_comp(4*elem-3,4)=s_aux1(2,2); %S22;
S_comp(4*elem-3,5)=s_aux1(2,1); %S12;
S_comp(4*elem-3,6)=s_max1; %Sppal_max;
S_comp(4*elem-3,7)=s_min1; %Sppal_min;
S_comp(4*elem-3,8)=s_vm1;%S_von mises;
S_comp(4*elem-3,9)=e_aux1(1,1); %e11;
S_comp(4*elem-3,10)=e_aux1(2,2); %e22;
S_comp(4*elem-3,11)=e_aux1(2,1); %e12;
e_aux1(2,1)=0.5*e_aux1(2,1);
e_aux1(1,2)=e_aux1(2,1);
e_princ1=eig(e_aux1);
e_max1=max(e_princ1);
e_min1=min(e_princ1);
if e_max1<0
e_max1=0;
end
if e_min1>0
e_min1=0;
end
S_comp(4*elem-3,12)=e_max1; %eppal_max;
S_comp(4*elem-3,13)=e_min1; %eppal_min;
S_comp(4*elem-2,1)=elem;
S_comp(4*elem-2,2)=nodo2;
S_comp(4*elem-2,3)=s_aux2(1,1); %S11;
S_comp(4*elem-2,4)=s_aux2(2,2); %S22;
S_comp(4*elem-2,5)=s_aux2(2,1); %S12;
S_comp(4*elem-2,6)=s_max2; %Sppal_max;
S_comp(4*elem-2,7)=s_min2; %Sppal_min;
S_comp(4*elem-2,8)=s_vm2;%S_von mises;
S_comp(4*elem-2,9)=e_aux2(1,1); %e11;
S_comp(4*elem-2,10)=e_aux2(2,2); %e22;
S_comp(4*elem-2,11)=e_aux2(2,1); %e12;
e_aux2(2,1)=0.5*e_aux2(2,1);
e_aux2(1,2)=e_aux2(2,1);
e_princ2=eig(e_aux2);
e_max2=max(e_princ2);
e_min2=min(e_princ2);
if e_max2<0
e_max2=0;
end
if e_min2>0
e_min2=0;
end
S_comp(4*elem-2,12)=e_max2; %eppal_max;
S_comp(4*elem-2,13)=e_min2; %eppal_min;
S_comp(4*elem-1,1)=elem;
S_comp(4*elem-1,2)=nodo3;
S_comp(4*elem-1,3)=s_aux3(1,1); %S11;
S_comp(4*elem-1,4)=s_aux3(2,2); %S22;
S_comp(4*elem-1,5)=s_aux3(2,1); %S12;
S_comp(4*elem-1,6)=s_max3; %Sppal_max;
S_comp(4*elem-1,7)=s_min3; %Sppal_min;
S_comp(4*elem-1,8)=s_vm3;%S_von mises;
S_comp(4*elem-1,9)=e_aux3(1,1); %e11;
S_comp(4*elem-1,10)=e_aux3(2,2); %e22;
S_comp(4*elem-1,11)=e_aux3(2,1); %e12;
e_aux3(2,1)=0.5*e_aux3(2,1);
e_aux3(1,2)=e_aux3(2,1);
e_princ3=eig(e_aux3);
e_max3=max(e_princ3);
e_min3=min(e_princ3);
if e_max3<0
e_max3=0;
end
if e_min3>0
e_min3=0;
end
S_comp(4*elem-1,12)=e_max3; %eppal_max;
S_comp(4*elem-1,13)=e_min3; %eppal_min;
S_comp(4*elem,1)=elem;
S_comp(4*elem,2)=nodo4;
S_comp(4*elem,3)=s_aux4(1,1); %S11;
S_comp(4*elem,4)=s_aux4(2,2); %S22;
S_comp(4*elem,5)=s_aux4(2,1); %S12;
S_comp(4*elem,6)=s_max4; %Sppal_max;
S_comp(4*elem,7)=s_min4; %Sppal_min;
S_comp(4*elem,8)=s_vm4;%S_von mises;
S_comp(4*elem,9)=e_aux4(1,1); %e11;
S_comp(4*elem,10)=e_aux4(2,2); %e22;
S_comp(4*elem,11)=e_aux4(2,1); %e12;
e_aux4(2,1)=0.5*e_aux4(2,1);
e_aux4(1,2)=e_aux4(2,1);
e_princ4=eig(e_aux4);
e_max4=max(e_princ4);
e_min4=min(e_princ4);
if e_max4<0
e_max4=0;
end
if e_min4>0
e_min4=0;
end
S_comp(4*elem,12)=e_max4; %eppal_max;
S_comp(4*elem,13)=e_min4; %eppal_min;
elseif n_filas==6 %Tensiones iguales en todo el elemento, ya que solo existe 1 pto de integración o de Gauss
for i=1:3
for j=1:n_filas
B_aux(i,j)=B_elementos(elem,i,j);
end
end
s_aux=D*B_aux*U_aux;
e_aux=inv(D)*s_aux;
%Ya tenemos calculadas las componentes tensiones en cada elemento
%En los elementos triangulares, las componentes son iguales en todos los
%nodos
%Construimos una matriz de tensiones por cada elemento en el que las filas
%sean los nodos(3 o 4 filas, segun el elemento) y las columnas sean:
%||
|
|
|
|
|
|
|
|
|
|
|
|
|
%||Elemento|Nodo|S11|S22|S12|S_Max.Ppal|S_Min.PPal|V.Mises|e11|e22|e12|e_Max.Ppal|e_Min.PPal|
%||
|
|
|
|
|
|
|
|
|
|
|
|
|
s_aux2(1,1)=s_aux(1,1); %S11;
s_aux2(2,2)=s_aux(2,1); %S22;
s_aux2(1,2)=s_aux(3,1); %S12;
s_aux2(2,1)=s_aux(3,1); %S12;
S_princ=eig(s_aux2);
s_max=max(S_princ);
s_min=min(S_princ);
s_vm=((s_max)^2+(s_min)^2-(s_max*s_min))^(0.5);
if s_max<0
s_max=0;
end
if s_min>0
s_min=0;
end
e_aux2(1,1)=e_aux(1,1); %e11;
e_aux2(2,2)=e_aux(2,1); %e22;
e_aux2(1,2)=0.5*e_aux(3,1); %e12;
e_aux2(2,1)=0.5*e_aux(3,1); %e12;
e_princ=eig(e_aux2);
e_max=max(e_princ);
e_min=min(e_princ);
if e_max<0
e_max=0;
end
if e_min>0
e_min=0;
end
S_comp(3*elem-2,1)=elem;
S_comp(3*elem-2,2)=nodo1;
S_comp(3*elem-2,3)=s_aux(1,1); %S11;
S_comp(3*elem-2,4)=s_aux(2,1); %S22;
S_comp(3*elem-2,5)=s_aux(3,1); %S12;
S_comp(3*elem-2,6)=s_max; %Sppal_max;
S_comp(3*elem-2,7)=s_min; %Sppal_min;
S_comp(3*elem-2,8)=s_vm;%S_von mises;
S_comp(3*elem-2,9)=e_aux(1,1); %e11;
S_comp(3*elem-2,10)=e_aux(2,1); %e22;
S_comp(3*elem-2,11)=e_aux(3,1); %e12;
S_comp(3*elem-2,12)=e_max; %eppal_max;
S_comp(3*elem-2,13)=e_min; %eppal_min;
S_comp(3*elem-1,1)=elem;
S_comp(3*elem-1,2)=nodo2;
S_comp(3*elem-1,3)=s_aux(1,1); %S11;
S_comp(3*elem-1,4)=s_aux(2,1); %S22;
S_comp(3*elem-1,5)=s_aux(3,1); %S12;
S_comp(3*elem-1,6)=s_max; %Sppal_max;
S_comp(3*elem-1,7)=s_min; %Sppal_min;
S_comp(3*elem-1,8)=s_vm;%S_von mises;
S_comp(3*elem-1,9)=e_aux(1,1); %e11;
S_comp(3*elem-1,10)=e_aux(2,1); %e22;
S_comp(3*elem-1,11)=e_aux(3,1); %e12;
S_comp(3*elem-1,12)=e_max; %eppal_max;
S_comp(3*elem-1,13)=e_min; %eppal_min;
S_comp(3*elem,1)=elem;
S_comp(3*elem,2)=nodo3;
S_comp(3*elem,3)=s_aux(1,1); %S11;
S_comp(3*elem,4)=s_aux(2,1); %S22;
S_comp(3*elem,5)=s_aux(3,1); %S12;
S_comp(3*elem,6)=s_max; %Sppal_max;
S_comp(3*elem,7)=s_min; %Sppal_min;
S_comp(3*elem,8)=s_vm;%S_von mises;
S_comp(3*elem,9)=e_aux(1,1); %e11;
S_comp(3*elem,10)=e_aux(2,1); %e22;
S_comp(3*elem,11)=e_aux(3,1); %e12;
S_comp(3*elem,12)=e_max; %eppal_max;
S_comp(3*elem,13)=e_min; %eppal_min;
end
end
%Tenemos los esfuerzos y deformaciones en cada uno de los nodos de cada
%elemento, pero en cada elemento ese valor varia, por lo que hay que
%calcular una media
[f c]=size(S_comp);
for valor=3:13
media=zeros(n_nodos,filas+3);
for nod=1:n_nodos
for filS=1:f
if S_comp(filS,2)==nod
media(nod,S_comp(filS,1))=S_comp(filS,valor);
media(nod,filas+1)=media(nod,filas+1)+S_comp(filS,valor);
media(nod,filas+2)=media(nod,filas+2)+1;
end
end
media(nod,filas+3)=media(nod,filas+1)/media(nod,filas+2);
for filS=1:f
if S_comp(filS,2)==nod
S_comp(filS,valor)=media(nod,filas+3);
end
end
end
end
%Rellenamos una tabla con la matriz de tensiones
t=handles.uitable4;
set(t,'Data',S_comp);
%Dibujamos los resultados
Redimensiona(handles)
%----------------------------------------------------------------------------function
Dibuja_malla_desp(datos_nodos,columna_nodos_colorear,desplz_orig,nodos_matriz,num_nodos,elem_matriz,color_int,color_ext,
handles)
% Funcion para pintar la malla
colum=columna_nodos_colorear;
%calculamos la matriz de coordenadas finales
coord_final=zeros(num_nodos,3);
esc_text=get(handles.edit4,'String');
escala=str2num(esc_text);
desplz_matriz(:,2)=escala*desplz_orig(:,2);
desplz_matriz(:,3)=escala*desplz_orig(:,3);
for i=1:num_nodos
col= nodos_matriz(i,1);
col1=col{1};
coord_final(i,1)=str2num(col1);
col= nodos_matriz(i,2);
col1=col{1};
coord_final(i,2)=str2num(col1)+desplz_matriz(i,2);
col= nodos_matriz(i,3);
col1=col{1};
coord_final(i,3)=str2num(col1)+desplz_matriz(i,3);
end
f2D_3 = [1,2,3];
f2D_4 = [1,2,3,4];
[nelem,n_nodos_x_elem]=size(elem_matriz);
n_nodos_x_elem=n_nodos_x_elem-1;
hold on
%calculamos el maximo y el minimo del resultado que queremos colorear
max_color=max(datos_nodos(:,colum));
min_color=min(datos_nodos(:,colum));
for lmn = 1:nelem
for i = 1:n_nodos_x_elem
col=elem_matriz(lmn,i+1);
col1=col{1};
id_nodo=str2num(col1);
x(i,1) = coord_final(id_nodo,2);
x(i,2) = coord_final(id_nodo,3);
fvc(i,:)=Calcula_color(datos_nodos(id_nodo,colum),max_color,min_color);
end
if (n_nodos_x_elem==3)
%crea el polígono definido por los vertices x, de nº de caras f2D_3 (3), rellenos de color azul ('b') y
laterales de color (variable color)
patch('Vertices',x,'Faces',f2D_3,'FaceVertexCData',fvc,'FaceColor',color_int,'EdgeColor',color_ext);
elseif (n_nodos_x_elem==4)
patch('Vertices',x,'Faces',f2D_4,'FaceVertexCData',fvc,'FaceColor',color_int,'EdgeColor',color_ext);
end
end
axis equal
hold off
colorbar('YTickLabel',{num2str(min_color+(0.0*(max_color-min_color))),...
num2str(min_color+(0.1*(max_color-min_color))),...
num2str(min_color+(0.2*(max_color-min_color))),...
num2str(min_color+(0.3*(max_color-min_color))),...
num2str(min_color+(0.4*(max_color-min_color))),...
num2str(min_color+(0.5*(max_color-min_color))),...
num2str(min_color+(0.6*(max_color-min_color))),...
num2str(min_color+(0.7*(max_color-min_color))),...
num2str(min_color+(0.8*(max_color-min_color))),...
num2str(min_color+(0.9*(max_color-min_color))),...
num2str(min_color+(1.0*(max_color-min_color)))})
%----------------------------------------------------------------------------function
Dibuja_malla_ten(datos_elem,columna_valor_colorear,desplz_orig,nodos_matriz,num_nodos,elem_matriz,color_int,color_ext,ha
ndles)
% Funcion para pintar la malla
colum=columna_valor_colorear;
%calculamos la matriz de coordenadas finales
coord_final=zeros(num_nodos,3);
esc_text=get(handles.edit4,'String');
escala=str2num(esc_text);
desplz_matriz(:,2)=escala*desplz_orig(:,2);
desplz_matriz(:,3)=escala*desplz_orig(:,3);
for i=1:num_nodos
col= nodos_matriz(i,1);
col1=col{1};
coord_final(i,1)=str2num(col1);
col= nodos_matriz(i,2);
col1=col{1};
coord_final(i,2)=str2num(col1)+desplz_matriz(i,2);
col= nodos_matriz(i,3);
col1=col{1};
coord_final(i,3)=str2num(col1)+desplz_matriz(i,3);
end
f2D_3 = [1,2,3];
f2D_4 = [1,2,3,4];
[nelem,n_nodos_x_elem]=size(elem_matriz);
n_nodos_x_elem=n_nodos_x_elem-1;
hold on
%calculamos el maximo y el minimo del resultado que queremos colorear
max_color=max(datos_elem(:,colum));
min_color=min(datos_elem(:,colum));
for lmn = 1:nelem
for i = 1:n_nodos_x_elem
col=elem_matriz(lmn,i+1);
col1=col{1};
id_nodo=str2num(col1);
x(i,1) = coord_final(id_nodo,2);
x(i,2) = coord_final(id_nodo,3);
%Dentro de la matriz de tensiones, buscamos cual es la fila
%que ocupa ese nodo de ese elemeno
if (n_nodos_x_elem==3)
fila_start=3*lmn-2;
elseif (n_nodos_x_elem==4)
fila_start=4*lmn-3;
end
for j=fila_start:(fila_start+n_nodos_x_elem-1)
if datos_elem(j,2)==id_nodo
break
end
end
fvc(i,:)=Calcula_color(datos_elem(j,colum),max_color,min_color);
end
if (n_nodos_x_elem==3)
%crea el polígono definido por los vertices x, de nº de caras f2D_3 (3), rellenos de color azul ('b') y
laterales de color (variable color)
patch('Vertices',x,'Faces',f2D_3,'FaceVertexCData',fvc,'FaceColor',color_int,'EdgeColor',color_ext);
elseif (n_nodos_x_elem==4)
patch('Vertices',x,'Faces',f2D_4,'FaceVertexCData',fvc,'FaceColor',color_int,'EdgeColor',color_ext);
end
end
axis equal
hold off
colorbar('YTickLabel',{num2str(min_color+(0.0*(max_color-min_color))),...
num2str(min_color+(0.1*(max_color-min_color))),...
num2str(min_color+(0.2*(max_color-min_color))),...
num2str(min_color+(0.3*(max_color-min_color))),...
num2str(min_color+(0.4*(max_color-min_color))),...
num2str(min_color+(0.5*(max_color-min_color))),...
num2str(min_color+(0.6*(max_color-min_color))),...
num2str(min_color+(0.7*(max_color-min_color))),...
num2str(min_color+(0.8*(max_color-min_color))),...
num2str(min_color+(0.9*(max_color-min_color))),...
num2str(min_color+(1.0*(max_color-min_color)))})
%Calculo del color
function col=Calcula_color(valor,max,min)
%calculamos los colores de cada uno de los vertices
%matriz de 3x3, 3 filas-->3 vertices, 3 columnas-->RGB
%vamos a colorear desplazamientos, que ya tenemos calculados
color_34=min+(0.75)*(max-min);
med_color=min+(0.5)*(max-min);
color_14=min+(0.25)*(max-min);
if valor==max
col(1,1) = 1;
col(1,2) = 0;
col(1,3) = 0;
elseif valor==color_34
col(1,1) = 1;
col(1,2) = 1;
col(1,3) = 0;
elseif valor==med_color
col(1,1) = 0;
col(1,2) = 1;
col(1,3) = 0;
elseif valor==color_14
col(1,1) = 0;
col(1,2) = 1;
col(1,3) = 1;
elseif valor==min
col(1,1) = 0;
col(1,2) = 0;
col(1,3) = 1;
end
if and(valor<max,valor>color_34)==1
col(1,1) = 1;
col(1,2) = ((color_34-valor)/(max-color_34))+1;
col(1,3) = 0;
elseif and(valor<color_34,valor>med_color)==1
col(1,1) = ((valor-med_color)/(color_34-med_color));
col(1,2) = 1;
col(1,3) = 0;
elseif and(valor<med_color,valor>color_14)==1
col(1,3) = ((color_14-valor)/(med_color-color_14))+1;
col(1,2) = 1;
col(1,1) = 0;
elseif and(valor<color_14,valor>min)==1
col(1,3) = 1;
col(1,2) = ((valor-min)/(color_14-min));
col(1,1) = 0;
end
% Calculo Del Área
function A = Area(coordenada_nodo1,coordenada_nodo2,coordenada_nodo3)
matriz=[ 1 coordenada_nodo1;...
1 coordenada_nodo2;...
1 coordenada_nodo3;];
A = 0.5*det(matriz);
%----------------------------------------------------------------------------function B_triang = calcular_B_triang(A,coordenada_nodo1,coordenada_nodo2,coordenada_nodo3)
b1 = coordenada_nodo2(2)-coordenada_nodo3(2);
b2 = coordenada_nodo3(2)-coordenada_nodo1(2);
b3 = coordenada_nodo1(2)-coordenada_nodo2(2);
c1 = coordenada_nodo3(1)-coordenada_nodo2(1);
c2 = coordenada_nodo1(1)-coordenada_nodo3(1);
c3 = coordenada_nodo2(1)-coordenada_nodo1(1);
B_triang = (1/(2*A))* [b1 0 b2 0 b3 0 ;...
0 c1 0 c2 0 c3;...
c1 b1 c2 b2 c3 b3];
%----------------------------------------------------------------------------function K = calcular_K_triang(A,coordenada_nodo1,coordenada_nodo2,coordenada_nodo3,young,poisson,esp)
b1 = coordenada_nodo2(2)-coordenada_nodo3(2);
b2 = coordenada_nodo3(2)-coordenada_nodo1(2);
b3 = coordenada_nodo1(2)-coordenada_nodo2(2);
c1 = coordenada_nodo3(1)-coordenada_nodo2(1);
c2 = coordenada_nodo1(1)-coordenada_nodo3(1);
c3 = coordenada_nodo2(1)-coordenada_nodo1(1);
B = (1/(2*A))* [b1 0 b2 0 b3 0 ;...
0 c1 0 c2 0 c3;...
c1 b1 c2 b2 c3 b3];
%Tension plana
d11=str2num(young)/(1-str2num(poisson).^2);
d12=(str2num(young)/(1-str2num(poisson).^2))*(str2num(poisson));
d13=0;
d21=(str2num(young)/(1-str2num(poisson).^2))*(str2num(poisson));
d22=(str2num(young)/(1-str2num(poisson).^2));
d23=0;
d31=0;
d32=0;
d33=(str2num(young)/(1-str2num(poisson).^2))*((1-str2num(poisson))/2);
D=[d11 d12 d13 ;...
d21 d22 d23 ;...
d31 d32 d33];
area_elemento=abs(Area(coordenada_nodo1,coordenada_nodo2,coordenada_nodo3));
aux=[1 0 0 0 0 0;
0 1 0 0 0 0;
0 0 1 0 0 0;
0 0 0 1 0 0;
0 0 0 0 1 0;
0 0 0 0 0 1];
aux=str2num(esp)*area_elemento*aux;
K=aux*B'*D*B;
%----------------------------------------------------------------------------function B_rect = calcular_B_rect(nodo,x,y)
if nodo==1
ri=1;
si=1;
elseif nodo==2
ri=2;
si=1;
elseif nodo==3
ri=1;
si=2;
elseif nodo==4
ri=2;
si=2;
end
%Valores de L para la integración numerca
pg = [sqrt(1/3); -sqrt(1/3)]; %pesos de gauss
r = pg(ri);
s = pg(si);
%%Calcular B del elemento
% Calculo de las derivadas de x e y respecto a los ejes coordenados
dxdr = 1/4*(1+s)*x(1,1)-1/4*(1+s)*x(1,2)-1/4*(1-s)*x(1,3)+1/4*(1-s)*x(1,4);
dxds = 1/4*(1+r)*x(1,1)+1/4*(1-r)*x(1,2)-1/4*(1-r)*x(1,3)-1/4*(1+r)*x(1,4);
dydr = 1/4*(1+s)*y(1,1)-1/4*(1+s)*y(1,2)-1/4*(1-s)*y(1,3)+1/4*(1-s)*y(1,4);
dyds = 1/4*(1+r)*y(1,1)+1/4*(1-r)*y(1,2)-1/4*(1-r)*y(1,3)-1/4*(1+r)*y(1,4);
% Calculo de las derivadas de las funciones de forma respecto a las
% coordenadas parametrizadas
dN1dr = 1/4 + 1/4*s;
dN1ds = 1/4 + 1/4*r;
dN2dr = -1/4 - 1/4*s;
dN2ds = 1/4 - 1/4*r;
dN3dr = -1/4 + 1/4*s;
dN3ds = -1/4 + 1/4*r;
dN4dr = 1/4 - 1/4*s;
dN4ds = -1/4 - 1/4*r;
% Almacenamiento del jacobiano
J1 = [dxdr dydr; ...
dxds dyds];
% Almacenamiento de la matriz de derivadas respecto a coordenadas
%parametrizadas
derN = [dN1dr dN2dr dN3dr dN4dr; ...
dN1ds dN2ds dN3ds dN4ds];
% Calculo de la matriz de derivadas de las funciones de forma respecto a
% los ejes coordenados
dN = (inv(J1)*derN)';
% Calculo de la matriz B
B_rect = [dN(1,1) 0 dN(2,1) 0 dN(3,1) 0 dN(4,1) 0; ...
0 dN(1,2) 0 dN(2,2) 0 dN(3,2) 0 dN(4,2); ...
dN(1,2) dN(1,1) dN(2,2) dN(2,1) dN(3,2) dN(3,1) dN(4,2) dN(4,1)];
%----------------------------------------------------------------------------function K = calcular_K_rect(x,y,young,poisson,esp)
%Tension plana
d11=str2num(young)/(1-str2num(poisson).^2);
d12=(str2num(young)/(1-str2num(poisson).^2))*(str2num(poisson));
d13=0;
d21=(str2num(young)/(1-str2num(poisson).^2))*(str2num(poisson));
d22=(str2num(young)/(1-str2num(poisson).^2));
d23=0;
d31=0;
d32=0;
d33=(str2num(young)/(1-str2num(poisson).^2))*((1-str2num(poisson))/2);
D=[d11 d12 d13 ;...
d21 d22 d23 ;...
d31 d32 d33];
%Valores de L para la integración numerca
pg = [sqrt(1/3); -sqrt(1/3)]; %pesos de gauss
K=zeros(8,8);
for veces=1:4
if veces==1
ri=1;
si=1;
elseif veces==2
ri=2;
si=1;
elseif veces==3
ri=1;
si=2;
elseif veces==4
ri=2;
si=2;
end
r = pg(ri);
s = pg(si);
%%Calcular B del elemento
% Calculo de las derivadas de x e y respecto a los ejes coordenados
dxdr = 1/4*(1+s)*x(1,1)-1/4*(1+s)*x(1,2)-1/4*(1-s)*x(1,3)+1/4*(1-s)*x(1,4);
dxds = 1/4*(1+r)*x(1,1)+1/4*(1-r)*x(1,2)-1/4*(1-r)*x(1,3)-1/4*(1+r)*x(1,4);
dydr = 1/4*(1+s)*y(1,1)-1/4*(1+s)*y(1,2)-1/4*(1-s)*y(1,3)+1/4*(1-s)*y(1,4);
dyds = 1/4*(1+r)*y(1,1)+1/4*(1-r)*y(1,2)-1/4*(1-r)*y(1,3)-1/4*(1+r)*y(1,4);
% Calculo de las derivadas de las funciones de forma respecto a las
% coordenadas parametrizadas
dN1dr = 1/4 + 1/4*s;
dN1ds = 1/4 + 1/4*r;
dN2dr = -1/4 - 1/4*s;
dN2ds = 1/4 - 1/4*r;
dN3dr = -1/4 + 1/4*s;
dN3ds = -1/4 + 1/4*r;
dN4dr = 1/4 - 1/4*s;
dN4ds = -1/4 - 1/4*r;
% Almacenamiento del jacobiano
J1 = [dxdr dydr; ...
dxds dyds];
detJ1 = det(J1);
% Almacenamiento de la matriz de derivadas respecto a coordenadas
%parametrizadas
derN = [dN1dr dN2dr dN3dr dN4dr; ...
dN1ds dN2ds dN3ds dN4ds];
% Calculo de la matriz de derivadas de las funciones de forma respecto a
% los ejes coordenados
dN = (inv(J1)*derN)';
% Calculo de la matriz B
B = [dN(1,1) 0 dN(2,1) 0 dN(3,1) 0 dN(4,1) 0; ...
0 dN(1,2) 0 dN(2,2) 0 dN(3,2) 0 dN(4,2); ...
dN(1,2) dN(1,1) dN(2,2) dN(2,1) dN(3,2) dN(3,1) dN(4,2) dN(4,1)];
%%Calcular K del elemento
aux = B'*D*B*detJ1*str2num(esp);
K = K + aux;
end
function popupmenu1_Callback(hObject, eventdata, handles)
Redimensiona(handles)
function popupmenu1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function axes1_CreateFcn(hObject, eventdata, handles)
function edit1_Callback(hObject, eventdata, handles)
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function figure_ResizeFcn(hObject, eventdata, handles)
function edit3_Callback(hObject, eventdata, handles)
function edit3_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function pushbutton3_Callback(hObject, eventdata, handles)
[archivo,ruta]=uigetfile('*.inp','ABRIR ARCHIVO');
set(handles.edit6,'String',ruta);
set(handles.edit5,'String',archivo);
%limpiamos la pantalla
cla
function edit4_Callback(hObject, eventdata, handles)
Redimensiona(handles);
function edit4_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit5_Callback(hObject, eventdata, handles)
function edit5_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit6_Callback(hObject, eventdata, handles)
function edit6_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Redimensiona(handles)
%generamos las matrices de Nodos, elementos y desplz y el valor de n_nodos
Nodos = get(handles.uitable1,'Data');
Elementos = get(handles.uitable2,'Data');
desplz = get(handles.uitable3,'Data');
S_matriz = get(handles.uitable4,'Data');
[n_nodos,col]=size(Nodos);
%Dibujamos el modelo sin deformar
desp_0=desplz;
for i=1:n_nodos
desp_0(i,2)=0;
desp_0(i,3)=0;
end
%limpiamos la pantalla
cla
valor=get(handles.popupmenu1,'Value');
if valor==1
%Dibujamos el modelo sin deformar
Dibuja_malla_desp(desplz,3,desp_0,Nodos,n_nodos,Elementos,'none','g',handles);
%alpha(0.5)
%Dibujamos la deformada
Dibuja_malla_desp(desplz,3,desplz,Nodos,n_nodos,Elementos,'interp','k',handles);
%alpha(0)
end
if valor==2
%Dibujamos el modelo sin deformar
Dibuja_malla_desp(desplz,2,desp_0,Nodos,n_nodos,Elementos,'none','g',handles);
%alpha(0.5)
%Dibujamos la deformada
Dibuja_malla_desp(desplz,2,desplz,Nodos,n_nodos,Elementos,'interp','k',handles);
%alpha(0)
end
if valor>2
%Dibujamos el modelo sin deformar
Dibuja_malla_ten(S_matriz,valor,desp_0,Nodos,n_nodos,Elementos,'none','g',handles);
%alpha(0.5)
%Dibujamos la deformada
Dibuja_malla_ten(S_matriz,valor,desplz,Nodos,n_nodos,Elementos,'interp','k',handles);
%alpha(0)
end
axes(handles.axes1); %selecciono el objeto de ejes axes1
zoom on; %activo el zoom sobre el eje seleccionado
Descargar