def mass_table(masses): from py2md.classes import MDTable masslst = [] if isinstance(masses, dict): masslst = [masses[m] for m in masses] elif isinstance(masses, list): masslst = masses table = MDTable() table.add_column('Name', 's') table.add_column('Mass', '.3f') table.add_column('xcm', '.3f') table.add_column('ycm', '.3f') table.add_column('zcm', '.3f') table.add_column('Ixx', '.1f') table.add_column('Ixy', '.1f') table.add_column('Ixz', '.1f') table.add_column('Iyy', '.1f') table.add_column('Iyz', '.1f') table.add_column('Izz', '.1f') for mass in masslst: table.add_row([ mass.name, mass.mass, mass.xcm, mass.ycm, mass.zcm, mass.Ixx, mass.Ixy, mass.Ixz, mass.Iyy, mass.Iyz, mass.Izz ]) return table
def point_loads_table(self, file=None): table = MDTable() table.add_column('#', 'd') table.add_column('x', '.3f') table.add_column('y', '.3f') table.add_column('z', '.3f') if self.strc.axis == 'y': table.add_column('Vx', '.1f') table.add_column('Fy', '.1f') table.add_column('Vz', '.1f') table.add_column('Mx', '.0f') table.add_column('Ty', '.0f') table.add_column('Mz', '.0f') elif self.strc.axis == 'z': table.add_column('Vx', '.1f') table.add_column('Vy', '.1f') table.add_column('Fz', '.1f') table.add_column('Mx', '.0f') table.add_column('My', '.0f') table.add_column('Tz', '.0f') for i in range(self.strc.pnts.shape[0]): frc = self.ptfrc[i, 0] mom = self.ptmom[i, 0] pnt = self.strc.pnts[i, 0] x, y, z = pnt.x, pnt.y, pnt.z Vx, Fy, Vz = frc.x, frc.y, frc.z Mx, Ty, Mz = mom.x, mom.y, mom.z table.add_row([i, x, y, z, Vx, Fy, Vz, Mx, Ty, Mz]) return table
def points_table(self): table = MDTable() table.add_column('#', 'd') table.add_column('x', '.5f') table.add_column('y', '.5f') table.add_column('z', '.5f') for i in range(self.pnts.shape[0]): pnt = self.pnts[i, 0] table.add_row([i, pnt.x, pnt.y, pnt.z]) return table
def print_gradient(self, frmstr='.6f'): u"""This function prints the gradient of the spline.""" from math import cos, sin, atan2, pi table = MDTable() table.add_column('ID', 'd') table.add_column('dxds', frmstr) table.add_column('dyds', frmstr) table.add_column('Tangent X', frmstr) table.add_column('Tangent Y', frmstr) for i in range(self.npnts): dxds = self.dr[i].x dyds = self.dr[i].y tanx = cos(atan2(dyds, dxds)) tany = sin(atan2(dyds, dxds)) table.add_row([i, dxds, dyds, tanx, tany]) print(table)
def panel_geometry(self): table = MDTable() table.add_column('#', 'd') table.add_column('X', '.5f') table.add_column('Y', '.5f') table.add_column('Z', '.5f') table.add_column('DX', '.5f') table.add_column('nx', '.5f') table.add_column('ny', '.5f') table.add_column('nz', '.5f') for pnl in self.pnls: j = pnl.lpid x = pnl.pntg.x y = pnl.pntg.y z = pnl.pntg.z dx = pnl.crd nx = pnl.nrml.x ny = pnl.nrml.y nz = pnl.nrml.z table.add_row([j, x, y, z, dx, nx, ny, nz]) return table
def strip_geometry(self): table = MDTable() table.add_column('#', 'd') table.add_column('xpos', '.5f') table.add_column('ypos', '.5f') table.add_column('Zle', '.5f') table.add_column('Chord', '.4f') table.add_column('Width', '.5f') table.add_column('Area', '.6f') table.add_column('Dihed', '.4f') table.add_column('Incid', '.4f') for strp in self.strps: j = strp.lsid xpos = strp.pnti.x ypos = strp.pnti.y zpos = strp.pnti.z chord = strp.chord width = strp.dst area = strp.area dihed = strp.dihedral twist = strp.twist table.add_row( [j, xpos, ypos, zpos, chord, width, area, dihed, twist]) return table
def __str__(self): from py2md.classes import MDTable outstr = '# ' + self.name + '\n' table = MDTable() table.add_column('Speed', 'g', data=[self.speed]) table.add_column('Density', 'g', data=[self.rho]) outstr += table._repr_markdown_() if self._phi is not None: table = MDTable() table.add_column('Label', 's') table.add_column('Type', 's') table.add_column('Value', 'g') table.add_row(['Di', 'Objective', self.return_induced_drag()]) if self.constr is not None: for constr in self.constr: val = constr.evaluate() table.add_row([constr.param, 'Constraint', val]) if self.record is not None: for record in self.record: val = record.evaluate() table.add_row([record.param, 'Record', val]) outstr += table._repr_markdown_() return outstr
def __str__(self): outstr = f'# {self.pres.name} Design Loads for ' + self.strc.srfc.name+'\n' table = MDTable() table.add_column('Reference', 's') table.add_column('x', '.3f') table.add_column('y', '.3f') table.add_column('z', '.3f') table.add_column('Fx', '.1f') table.add_column('Fy', '.1f') table.add_column('Fz', '.1f') table.add_column('Mx', '.1f') table.add_column('My', '.1f') table.add_column('Mz', '.1f') x = self.rref.x y = self.rref.y z = self.rref.z Fx = self.frctot.x Fy = self.frctot.y Fz = self.frctot.z Mx = self.momtot.x My = self.momtot.y Mz = self.momtot.z table.add_row(['Total', x, y, z, Fx, Fy, Fz, Mx, My, Mz]) outstr += str(table) table = MDTable() table.add_column('Reaction', 'd') table.add_column('x', '.3f') table.add_column('y', '.3f') table.add_column('z', '.3f') table.add_column('Fx', '.1f') table.add_column('Fy', '.1f') table.add_column('Fz', '.1f') table.add_column('Mx', '.1f') table.add_column('My', '.1f') table.add_column('Mz', '.1f') for i, rpnt in enumerate(self.strc.rpnts): rfrc = self.rfrc[i] rmom = self.rmom[i] table.add_row([i+1, rpnt.x, rpnt.y, rpnt.z, rfrc.x, rfrc.y, rfrc.z, rmom.x, rmom.y, rmom.z]) outstr += str(table) table = MDTable() table.add_column('Value', 's') if self.strc.axis == 'y': table.add_column('Vx', '.1f') table.add_column('Fy', '.1f') table.add_column('Vz', '.1f') table.add_column('Mx', '.1f') table.add_column('Ty', '.1f') table.add_column('Mz', '.1f') elif self.strc.axis == 'z': table.add_column('Vx', '.1f') table.add_column('Vy', '.1f') table.add_column('Fz', '.1f') table.add_column('Mx', '.1f') table.add_column('My', '.1f') table.add_column('Tz', '.1f') Vx = self.frcmin.x Fy = self.frcmin.y Vz = self.frcmin.z Mx = self.mommin.x Ty = self.mommin.y Mz = self.mommin.z table.add_row(['Min', Vx, Fy, Vz, Mx, Ty, Mz]) Vx = self.frcmax.x Fy = self.frcmax.y Vz = self.frcmax.z Mx = self.mommax.x Ty = self.mommax.y Mz = self.mommax.z table.add_row(['Max', Vx, Fy, Vz, Mx, Ty, Mz]) outstr += str(table) return outstr
# | Value 1 | Value 2 | Value 3 | #%% # Import Dependencies from IPython.display import display from matplotlib.pyplot import figure from py2md.classes import MDTable #%% # Create Table table = MDTable() table.add_column('y', '.2f') table.add_column('z', '.2f') print(table.columns[0].length) print(table.columns[1].length) table.add_row([15.0, 1000.0]) print(table.columns[0].length) print(table.columns[1].length) display(table) #%% # [markdown] # # Latex Equations # $$ # \begin{bmatrix} # 2.0 & 5.0 \\ # 4.4 & 5.2 # \end{bmatrix} # $$ # $$