/// <summary> ///Calculates the element stiffness matrix used for warping analysis ///and the torsion load vector. /// </summary> /// <param name="mat"></param> /// <param name="coords"></param> /// <returns>Element stiffness matrix *(k_el)* and element torsion load vector* (f_el) *</returns> internal void torsion_properties(SectionMaterial mat, ExtendedTri tri, out double[,] k_el, out double[] f_el) { //# initialise stiffness matrix and load vector k_el = new double[6, 6]; f_el = new double[6]; //# Gauss points for 6 point Gaussian integration var gps = ShapeFunctionHelper.gauss_points(6); var Nxy = new double[2]; for (int i = 0; i < gps.RowCount(); i++) { var gp = gps.Row(i); var B = tri.ShapeInfo[i].B; double[] N = tri.ShapeInfo[i].N; double j = tri.ShapeInfo[i].j; //# determine x and y position at Gauss point var Nx = N.Dot(tri.coords.Row(0)); var Ny = N.Dot(tri.coords.Row(1)); var B_Transpose = B.Transpose(); //# calculated modulus weighted stiffness matrix and load vector k_el.Append(B_Transpose.Dot(B).Dot(gp[0] * j * mat.elastic_modulus)); Nxy[0] = Ny; Nxy[1] = -Nx; f_el.Append(B_Transpose.Dot(Nxy).Dot(gp[0] * j * mat.elastic_modulus)); } }
public SectionAttributes(SectionMaterial newMat, SectionWeapon newWeapon) { this.material = newMat; this.weapon = newWeapon; this.sp = this.material.GetInitialSP(); this.maxSP = this.material.GetMaxSP() - this.weapon.GetSPCost(); this.height = 0; }
public Build(int t, SectionMaterial m, SectionWeapon w) : base("Build") { this.playerNumber = TurnOrder.myPlayer.playerNumber; this.towerNumber = t; this.material = EncodeMaterial(m); this.weapon = EncodeWeapon(w); this.cost = m.GetCost() + w.GetCost(); }
public void ISec_Test() { SectionDefinition sec = new SectionDefinition(nameof(ISec_Test)); sec.SolutionSettings = new SolutionSettings(0.01); SectionMaterial steel = new SectionMaterial("Steel", 1, 200e3, 0.3, 500); sec.Contours.Add(new SectionContour(helper.CreateIShape(304, 165, 10.2, 6.1, 11.4, 8), false, steel)); _solver.Solve(sec); Compare(nameof(ISec_Test), sec); }
static void Main(string[] args) { Console.WriteLine("Starting..."); Stopwatch sw = new Stopwatch(); sw.Start(); Solver _solver = new Solver(); ShapeGeneratorHelper helper = new ShapeGeneratorHelper(); SectionMaterial defaultMat = new SectionMaterial("dummy", 1, 1.0, 0.0, 1.0); SectionDefinition sec = new SectionDefinition(); sec.SolutionSettings = new SolutionSettings(0.002); sec.Contours.Add(new SectionContour(helper.CreateRectangle(300, 180), false, defaultMat)); var c1 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat); c1.ShiftPoints(30, 30); var c2 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat); c2.ShiftPoints(150, 30); var c3 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat); c3.ShiftPoints(150, 270); var c4 = new SectionContour(helper.CreateCircle(15, 50), true, defaultMat); c4.ShiftPoints(30, 270); sec.Contours.Add(c1); sec.Contours.Add(c2); sec.Contours.Add(c3); sec.Contours.Add(c4); _solver.Solve(sec); Console.WriteLine(sec.Output.SectionProperties.j.ToString()); sw.Stop(); Console.WriteLine("Elapsed={0}", sw.Elapsed); Console.ReadLine(); }
private void StartBuild(Player player, Tower t, SectionMaterial m, SectionWeapon w) { GameObject block = null; GameObject weapon = null; Section topOfTower = t.GetTopSection(); GameObject playerSpot = t.towerBase.towerPoint; if(topOfTower == null) { spawnPoint.transform.position = playerSpot.transform.position; spawnPoint.transform.Translate(0,25,0); } else { Vector3 old = playerSpot.transform.position; spawnPoint.transform.position = new Vector3(old.x, topOfTower.collider.bounds.max.y, old.z); spawnPoint.transform.Translate(0,25,0); } block = Instantiate(m.GetPrefab(),spawnPoint.transform.position,Quaternion.identity) as GameObject; if(player.playerNumber == 1) { block.transform.rotation = Quaternion.AngleAxis(90, Vector3.up); } else if(player.playerNumber ==2) { block.transform.rotation = Quaternion.AngleAxis(-90, Vector3.up); } block.transform.Find("FireCam").camera.enabled = false; block.transform.Find("HitCam").camera.enabled = false; block.transform.Find("CollapseCam").camera.enabled = false; if (w.wtype != "Nothing"){ weapon = Instantiate(w.GetPrefab()) as GameObject; //I believe the here lies the issue for why building Nothing doesn't work? maybe. if(player.playerNumber == 1) { weapon.transform.rotation = Quaternion.AngleAxis(90, Vector3.up); } else if(player.playerNumber ==2) { weapon.transform.rotation = Quaternion.AngleAxis(-90, Vector3.up); } //if(weapon != null) { Vector3 localScale = weapon.transform.localScale; weapon.transform.parent = block.transform; weapon.transform.localPosition = block.transform.Find("WeaponLocation").localPosition; weapon.transform.localScale = localScale; } Section sc = block.GetComponent<Section>(); SectionAttributes s = new SectionAttributes(m, w); sc.attributes = s; player.Build(sc, t); TowerSelection.LocalSelectSection(t, sc.attributes.height); }
public void CompositeSec_Test() { //Note that because of using more than one material, some output need to be mapped to eq. material (e.g. Sx output represents Mpx and Sx= Mpx/fy) SectionMaterial steel = new SectionMaterial("Steel", 1, 200e3, 0.3, 500); var timber = new SectionMaterial("Timber", 2, 8e3, 0.35, 20); SectionDefinition sec = new SectionDefinition(nameof(CompositeSec_Test)); sec.SolutionSettings = new SolutionSettings(0.01); sec.Contours.Add(new SectionContour(helper.CreateIShape(304, 165, 10.2, 6.1, 11.4, 8), false, steel)); var panel = new SectionContour(helper.CreateRectangle(50, 600), false, timber); panel.ShiftPoints(-217.5, 304); sec.Contours.Add(panel); _solver.Solve(sec); Compare(nameof(CompositeSec_Test), sec); }
shear_warping_integrals(SectionMaterial mat, ExtendedTri tri, double ixx, double iyy, double ixy, double[] omega) { //# initialise integrals var sc_xint = 0.0; var sc_yint = 0.0; var q_omega = 0.0; var i_omega = 0.0; var i_xomega = 0.0; var i_yomega = 0.0; var gps = ShapeFunctionHelper.gauss_points(6); for (int i = 0; i < gps.RowCount(); i++) { var gp = gps.Row(i); double[] N = tri.ShapeInfo[i].N; double j = tri.ShapeInfo[i].j; //# determine x and y position at Gauss point var Nx = N.Dot(tri.coords.Row(0)); var Ny = N.Dot(tri.coords.Row(1)); var Nomega = N.Dot(omega); sc_xint += gp[0] * (iyy * Nx + ixy * Ny) * (Nx * Nx + Ny * Ny) * j * mat.elastic_modulus; sc_yint += gp[0] * (ixx * Ny + ixy * Nx) * (Nx * Nx + Ny * Ny) * j * mat.elastic_modulus; q_omega += gp[0] * Nomega * j * mat.elastic_modulus; i_omega += gp[0] * Nomega * Nomega * j * mat.elastic_modulus; i_xomega += gp[0] * Nx * Nomega * j * mat.elastic_modulus; i_yomega += gp[0] * Ny * Nomega * j * mat.elastic_modulus; } return(sc_xint, sc_yint, q_omega, i_omega, i_xomega, i_yomega); }
private int EncodeMaterial(SectionMaterial m) { return GetTower().faction.EncodeSectionMaterial(m.mtype); }
/// <summary> /// Calculates total force resisted by the element when subjected to a /// stress equal to the yield strength. Also returns the modulus weighted /// area and first moments of area, and determines whether or not the /// element is above or below the line defined by the unit vector *u* and /// point* p*. /// </summary> /// <param name="mat"></param> /// <param name="coords"></param> /// <param name="u">Unit vector in the direction of the line</param> /// <param name="p">Point on the line</param> /// <returns></returns> public (double f_el, double ea_el, double qx_el, double qy_el, bool is_above) plastic_properties(SectionMaterial mat, double[,] coords, double[] u, double[] p) { //# initialise geometric properties var e = mat.elastic_modulus; var area = 0.0; var qx = 0.0; var qy = 0.0; var force = 0.0; var gps = ShapeFunctionHelper.gauss_points(3); double[] N; double j; double[,] B; for (int i = 0; i < gps.RowCount(); i++) { var gp = gps.Row(i); ShapeFunctionHelper.shape_function(coords, gp, out N, out B, out j); area += gp[0] * j; var x = N.Dot(coords.Row(1)); var y = N.Dot(coords.Row(0)); qx += gp[0] * x * j; qy += gp[0] * y * j; force += gp[0] * j * mat.yield_strength; } //# calculate element centroid var cx = qy / area; var cy = qx / area; //# determine if the element is above the line p + u bool is_above = point_above_line(u, p[0], p[1], cx, cy); return(force, area *e, qx *e, qy *e, is_above); }
/// <summary> /// Calculates the integrals used to evaluate the monosymmetry constant about both global axes and both prinicipal axes. /// </summary> /// <param name="mat"></param> /// <param name="coords"></param> /// <param name="phi">Principal bending axis angle</param> /// <returns></returns> internal (double int_x, double int_y, double int_11, double int_22) monosymmetry_integrals(SectionMaterial mat, ExtendedTri tri, double phi) { //# initialise integrals var int_x = 0.0; var int_y = 0.0; var int_11 = 0.0; var int_22 = 0.0; var gps = ShapeFunctionHelper.gauss_points(6); for (int i = 0; i < gps.RowCount(); i++) { var gp = gps.Row(i); double[] N = tri.ShapeInfo[i].N; double j = tri.ShapeInfo[i].j; //# determine x and y position at Gauss point var Nx = N.Dot(tri.coords.Row(0)); var Ny = N.Dot(tri.coords.Row(1)); //# determine 11 and 22 position at Gauss point (var Nx_11, var Ny_22) = principal_coordinate(phi, Nx, Ny); //# weight the monosymmetry integrals by the section elastic modulus int_x += (gp[0] * (Nx * Nx * Ny + Ny * Ny * Ny) * j * mat.elastic_modulus); int_y += (gp[0] * (Ny * Ny * Nx + Nx * Nx * Nx) * j * mat.elastic_modulus); int_11 += (gp[0] * (Nx_11 * Nx_11 * Ny_22 + Ny_22 * Ny_22 * Ny_22) * j * mat.elastic_modulus); int_22 += (gp[0] * (Ny_22 * Ny_22 * Nx_11 + Nx_11 * Nx_11 * Nx_11) * j * mat.elastic_modulus); } return(int_x, int_y, int_11, int_22); }
/// <summary> /// Calculates the variables used to determine the shear deformation coefficients. /// </summary> /// <param name="mat"></param> /// <param name="coords"></param> /// <param name="ixx">Second moment of area about the centroidal x-axis</param> /// <param name="iyy">Second moment of area about the centroidal y-axis</param> /// <param name="ixy">Second moment of area about the centroidal xy-axis</param> /// <param name="psi_shear">Values of the psi shear function at the element nodes</param> /// <param name="phi_shear">Values of the phi shear function at the element nodes</param> /// <param name="nu">Effective Poisson's ratio for the cross-section</param> /// <returns></returns> internal (double kappa_x, double kappa_y, double kappa_xy) shear_coefficients(SectionMaterial mat, ExtendedTri tri, double ixx, double iyy, double ixy, double[] psi_shear, double[] phi_shear, double nu) { //# initialise integrals var kappa_x = 0.0; var kappa_y = 0.0; var kappa_xy = 0.0; var gps = ShapeFunctionHelper.gauss_points(6); var d = new double[2]; var h = new double[2]; //var psi_shear = new Vector(psi_shear2); //var phi_shear = new Vector(phi_shear2); for (int i = 0; i < gps.RowCount(); i++) { var gp = gps.Row(i); var B = tri.ShapeInfo[i].B; double[] N = tri.ShapeInfo[i].N; double j = tri.ShapeInfo[i].j; //# determine x and y position at Gauss point var Nx = N.Dot(tri.coords.Row(0)); var Ny = N.Dot(tri.coords.Row(1)); //# determine shear parameters var r = Nx * Nx - Ny * Ny; var q = 2 * Nx * Ny; var d1 = ixx * r - ixy * q; var d2 = ixy * r + ixx * q; var h1 = -ixy * r + iyy * q; var h2 = -iyy * r - ixy * q; d[0] = d1; d[1] = d2; h[0] = h1; h[1] = h2; var B_Transpose = B.Transpose(); var psi_shearXB_Transpose = psi_shear.Dot(B_Transpose).Subtract(d.Dot(nu / 2)); var BXphi_shear = B.Dot(phi_shear).Subtract(h.Dot(nu / 2)); kappa_x += psi_shearXB_Transpose.Dot(B.Dot(psi_shear).Subtract(d.Dot(nu / 2))) * (gp[0] * j * mat.elastic_modulus); kappa_y += phi_shear.Dot(B_Transpose).Subtract(h.Dot(nu / 2)).Dot(BXphi_shear) * gp[0] * j * mat.elastic_modulus; kappa_xy += psi_shearXB_Transpose.Dot(BXphi_shear) * (gp[0] * j * mat.elastic_modulus); } return(kappa_x, kappa_y, kappa_xy); }
/// <summary> /// Calculates the element shear load vectors used to evaluate the shear functions. /// </summary> /// <param name="mat"></param> /// <param name="coords"></param> /// <param name="ixx">Second moment of area about the centroidal x-axis</param> /// <param name="iyy">Second moment of area about the centroidal y-axis</param> /// <param name="ixy">Second moment of area about the centroidal xy-axis</param> /// <param name="nu">Effective Poisson's ratio for the cross-section</param> /// <returns>Element shear load vector psi *(f_psi)* and phi *(f_phi)*</returns> internal (double[] f_psi, double[] f_phi) shear_load_vectors(SectionMaterial mat, ExtendedTri tri, double ixx, double iyy, double ixy, double nu) { //# initialise stiffness matrix and load vector var f_psi = new double[6]; var f_phi = new double[6]; //# Gauss points for 6 point Gaussian integration var gps = ShapeFunctionHelper.gauss_points(6); var d = new double[2]; var h = new double[2]; for (int i = 0; i < gps.RowCount(); i++) { var gp = gps.Row(i); // shape_function(coords, gp, out N, ref B, out j); var B = tri.ShapeInfo[i].B; double[] N = tri.ShapeInfo[i].N; double j = tri.ShapeInfo[i].j; //# determine x and y position at Gauss point var Nx = N.Dot(tri.coords.Row(0)); var Ny = N.Dot(tri.coords.Row(1)); //# determine shear parameters var r = Nx * Nx - Ny * Ny; var q = 2 * Nx * Ny; var d1 = ixx * r - ixy * q; var d2 = ixy * r + ixx * q; var h1 = -ixy * r + iyy * q; var h2 = -iyy * r - ixy * q; //d[0, 0] = d1; //d[1, 0] = d2; //h[0, 0] = h1; //h[1, 0] = h2; //var B_Transpose = B.Transpose; //Vector tmp = new Vector(N); //tmp *= 2 * (1 + nu); //f_psi += gp[0] * (nu / 2 * (B_Transpose * d).Transpose.Row(0) + // tmp * (ixx * Nx - ixy * Ny)) * j * mat.elastic_modulus; //f_phi += gp[0] * (nu / 2 * (B_Transpose * h).Transpose.Row(0) + // tmp * (iyy * Ny - ixy * Nx)) * j * mat.elastic_modulus; d[0] = d1; d[1] = d2; h[0] = h1; h[1] = h2; var B_Transpose = B.Transpose(); var NN = N.Dot(2 * (1 + nu)); f_psi.Append(B_Transpose.Dot(d).Dot(nu / 2).Append(NN.Dot(ixx * Nx - ixy * Ny)).Dot(gp[0] * j * mat.elastic_modulus)); f_phi.Append(B_Transpose.Dot(h).Dot(nu / 2).Append(NN.Dot(iyy * Ny - ixy * Nx)).Dot(gp[0] * j * mat.elastic_modulus)); } return(f_psi, f_phi); }
public static void BuildSection(Player p, Tower t, SectionMaterial material, SectionWeapon weapon) { instance.StartBuild(p, t, material, weapon); }