def from_table(cls, n, file, sheet_name=0): """Instantiate a bearing using inputs from an Excel table. A header with the names of the columns is required. These names should match the names expected by the routine (usually the names of the parameters, but also similar ones). The program will read every row bellow the header until they end or it reaches a NaN. Parameters ---------- n : int The node in which the bearing will be located in the rotor. file: str Path to the file containing the bearing parameters. sheet_name: int or str, optional Position of the sheet in the file (starting from 0) or its name. If none is passed, it is assumed to be the first sheet in the file. Returns ------- A bearing object. """ parameters = read_table_file(file, "bearing", sheet_name, n) return cls( n=parameters["n"], kxx=parameters["kxx"], cxx=parameters["cxx"], kyy=parameters["kyy"], kxy=parameters["kxy"], kyx=parameters["kyx"], cyy=parameters["cyy"], cxy=parameters["cxy"], cyx=parameters["cyx"], w=parameters["w"], )
def from_table(cls, file, sheet_name=0): """Instantiate one or more disks using inputs from an Excel table. A header with the names of the columns is required. These names should match the names expected by the routine (usually the names of the parameters, but also similar ones). The program will read every row bellow the header until they end or it reaches a NaN. Parameters ---------- file: str Path to the file containing the disk parameters. sheet_name: int or str, optional Position of the sheet in the file (starting from 0) or its name. If none is passed, it is assumed to be the first sheet in the file. Returns ------- disk : list A list of disk objects. Examples -------- >>> import os >>> file_path = os.path.dirname(os.path.realpath(__file__)) + '/tests/data/shaft_si.xls' >>> list_of_disks = DiskElement.from_table(file_path, sheet_name="More") >>> list_of_disks[0] DiskElement(Id=0.0, Ip=0.0, m=15.12, color='#bc625b', n=4, tag=None) """ parameters = read_table_file(file, "disk", sheet_name=sheet_name) list_of_disks = [] for i in range(0, len(parameters["n"])): list_of_disks.append( cls( n=parameters["n"][i], m=parameters["m"][i], Id=float(parameters["Id"][i]), Ip=float(parameters["Ip"][i]), )) return list_of_disks
def from_table(cls, n, file, sheet_name=0, **kwargs): """Instantiate a bearing using inputs from an Excel table. A header with the names of the columns is required. These names should match the names expected by the routine (usually the names of the parameters, but also similar ones). The program will read every row bellow the header until they end or it reaches a NaN. Parameters ---------- n : int The node in which the bearing will be located in the rotor. file: str Path to the file containing the bearing parameters. sheet_name: int or str, optional Position of the sheet in the file (starting from 0) or its name. If none is passed, it is assumed to be the first sheet in the file. Returns ------- bearing: rs.BearingElement A bearing object. Examples -------- >>> import os >>> file_path = os.path.dirname(os.path.realpath(__file__)) + '/tests/data/bearing_seal_si.xls' >>> BearingElement.from_table(0, file_path) # doctest: +ELLIPSIS BearingElement(n=0, n_link=None, kxx=[... """ parameters = read_table_file(file, "bearing", sheet_name, n) return cls( n=parameters["n"], kxx=parameters["kxx"], cxx=parameters["cxx"], kyy=parameters["kyy"], kxy=parameters["kxy"], kyx=parameters["kyx"], cyy=parameters["cyy"], cxy=parameters["cxy"], cyx=parameters["cyx"], frequency=parameters["frequency"], **kwargs, )
def from_table(cls, file, sheet_name=0, tag=None, scale_factor=None, color=None): """Instantiate one or more disks using inputs from an Excel table. A header with the names of the columns is required. These names should match the names expected by the routine (usually the names of the parameters, but also similar ones). The program will read every row bellow the header until they end or it reaches a NaN. Parameters ---------- file : str Path to the file containing the disk parameters. sheet_name : int or str, optional Position of the sheet in the file (starting from 0) or its name. If none is passed, it is assumed to be the first sheet in the file. tag_list : list, optional list of tags for the disk elements. Default is None scale_factor: list, optional List of scale factors for the disk elements patches. The scale factor is used to scale the disk drawing. Default is 1. color : list, optional A color to be used when the element is represented. Default is 'Firebrick'. Returns ------- disk : list A list of disk objects. Examples -------- >>> import os >>> file_path = os.path.dirname(os.path.realpath(__file__)) + '/tests/data/shaft_si.xls' >>> list_of_disks = DiskElement.from_table(file_path, sheet_name="More") >>> list_of_disks[0] DiskElement(Id=0.0, Ip=0.0, m=15.12, color='Firebrick', n=3, tag=None) """ parameters = read_table_file(file, "disk", sheet_name=sheet_name) if tag is None: tag = [None] * len(parameters["n"]) if scale_factor is None: scale_factor = [1] * len(parameters["n"]) if color is None: color = ["Firebrick"] * len(parameters["n"]) list_of_disks = [] for i in range(0, len(parameters["n"])): list_of_disks.append( cls( n=parameters["n"][i], m=parameters["m"][i], Id=float(parameters["Id"][i]), Ip=float(parameters["Ip"][i]), tag=tag[i], scale_factor=scale_factor[i], color=color[i], )) return list_of_disks
def from_table(cls, file, sheet_type="Simple", sheet_name=0): """Instantiate one or more shafts using inputs from an Excel table. A header with the names of the columns is required. These names should match the names expected by the routine (usually the names of the parameters, but also similar ones). The program will read every row bellow the header until they end or it reaches a NaN. Parameters ---------- file: str Path to the file containing the shaft parameters. sheet_type: str, optional Describes the kind of sheet the function should expect: Simple: The input table should specify only the number of the materials to be used. They must be saved prior to calling the method. Model: The materials parameters must be passed along with the shaft parameters. Each material must have an id number and each shaft must reference one of the materials ids. sheet_name: int or str, optional Position of the sheet in the file (starting from 0) or its name. If none is passed, it is assumed to be the first sheet in the file. Returns ------- shaft: list A list of shaft objects. """ parameters = read_table_file( file, "shaft", sheet_name=sheet_name, sheet_type=sheet_type ) list_of_shafts = [] if sheet_type == "Model": new_materials = {} for i in range(0, len(parameters["matno"])): new_material = Material( name="shaft_mat_" + str(parameters["matno"][i]), rho=parameters["rhoa"][i], E=parameters["ea"][i], G_s=parameters["ga"][i], ) new_materials["shaft_mat_" + str(parameters["matno"][i])] = new_material for i in range(0, len(parameters["L"])): list_of_shafts.append( cls( L=parameters["L"][i], idl=parameters["idl"][i], odl=parameters["odl"][i], idr=parameters["idr"][i], odr=parameters["odr"][i], material=new_materials[parameters["material"][i]], n=parameters["n"][i], axial_force=parameters["axial_force"][i], torque=parameters["torque"][i], shear_effects=parameters["shear_effects"][i], rotary_inertia=parameters["rotary_inertia"][i], gyroscopic=parameters["gyroscopic"][i], shear_method_calc=parameters["shear_method_calc"][i], ) ) elif sheet_type == "Simple": for i in range(0, len(parameters["L"])): list_of_shafts.append( cls( L=parameters["L"][i], idl=parameters["idl"][i], odl=parameters["odl"][i], idr=parameters["idr"][i], odr=parameters["odr"][i], material=parameters["material"][i], n=parameters["n"][i], axial_force=parameters["axial_force"][i], torque=parameters["torque"][i], shear_effects=parameters["shear_effects"][i], rotary_inertia=parameters["rotary_inertia"][i], gyroscopic=parameters["gyroscopic"][i], shear_method_calc=parameters["shear_method_calc"][i], ) ) return list_of_shafts