def saveMat(self): self.transferTo() filename = QtGui.QFileDialog.getSaveFileName( None, 'Save Material file file', self.params.GetString("MaterialDir", '/'), 'FreeCAD material file (*.FCMat)') if (filename): import Material Material.exportFCMat(filename, self.obj.Material)
def saveMat(self): self.transferTo() filename = QtGui.QFileDialog.getSaveFileName( None, "Save Material file file", self.params.GetString("MaterialDir", "/"), "FreeCAD material file (*.FCMat)", ) if filename: import Material Material.exportFCMat(filename, self.obj.Material)
def define_material(self, subject, material_type, screen): file = open(self.materials_list, "r", encoding="utf-8") lines = file.readlines() lines = [line.rstrip() for line in lines] subject_index = None type_index = None separator = '------' materials_list = [] # Searching for subject in file for line in lines: if subject in line: subject_index = lines.index(line) # Define index of subject(number of line in file) # Searching for material type for line in lines[subject_index:]: if material_type in line: type_index = lines.index(line) # Define index of material type # Creating materials list, and filling it material_index = 0 materials_list.append(Material.create_material(material_type)) for line in lines[type_index:]: curr_material = materials_list[material_index] # Ends searching if separator found if separator in line: break # Create new material if '' is line.lstrip() and materials_list: materials_list.append(Material.create_material(material_type)) material_index += 1 continue # Filling up material properties string = line.lstrip()[:line.index(':') - 2] # Removing '\t' symbols keys = curr_material.keys # Get keys from certain material type (BOOK for example) if string in keys: # Searching for keys # Defining values of fields data = line.lstrip() data = line[line.index(':') + 2:] curr_material.properties[string] = data # screen.description.append(string + '\n' + data + '\n') if string == "NAME": # Adding to list of titles screen.titles_list.addItem(curr_material.properties[string]) break break self.materials = materials_list file.close()
def readMtl(self, fp): fp.readline() #mtlname line = fp.readline().decode() lst = line.split() assert lst[0] == "Kd" Kd = [float(q) for q in lst[1:4]] line = fp.readline().decode().strip() lst = line.split() assert lst[0] == "shininess" shininess = lst[1] line = fp.readline().decode().strip() lst = line.split() assert lst[0] == "specular" specular = [float(q) for q in lst[1:4]] line = fp.readline().decode().strip() if line.startswith("map_Kd"): lst = line.split(" ", 1) tex = ImageTexture2DArray(os.path.join("assets", lst[1].strip())) line = fp.readline().decode() else: tex = ImageTexture2DArray(os.path.join("assets", "white.png")) #range assert line.startswith("range") lst = line.split() start = int(lst[1]) * 4 count = int(lst[2]) m = Material() m.diffuse = vec3(*Kd) m.tex = tex m.start = start m.count = count m.shininess = float(shininess) m.specular = vec3(*specular) self.materials.append(m) return
def __init__(self, substrate="InP", materials=["InGaAs", "AlInAs"], moleFracs=[0.53, 0.52], xres=0.5, Eres=0.5, layerWidths=[0.0], layerMtrls=[0], layerDopings=[0.0], layerARs=[True], EField=0, repeats=3, T=300.0, Solver="ODE", description=""): self.substrate = substrate self.materials = materials self.moleFracs = moleFracs self.xres = xres self.Eres = Eres self.layerWidths = layerWidths self.layerMtrls = layerMtrls self.layerDopings = layerDopings self.layerARs = layerARs self.EField = EField self.repeats = repeats self.Temperature = T self.Solver = Solver self.description = description self.NonParabolic = True self.layerSelected = None self.subM = Material.Material(self.substrate, self.Temperature) self.update_strain()
def __init__(self, parent=None): super(MainWin, self).__init__(parent) QTextCodec.setCodecForLocale(QTextCodec.codecForName('utf8')) self.setupUi(self) self.p = Material.Penguin() self.firstCheck() self.CreateTab.triggered.connect(self.addNewTab) self.DeleteTab.triggered.connect(self.delTab) self.Scan.triggered.connect(self.ScanEq) self.DeleteAllLog.triggered.connect(self.delLog) self.Help.triggered.connect(self.showHelp) self.Author.triggered.connect(self.showAuthor) self.Soft.triggered.connect(self.showSoft) self.UnScan.triggered.connect(self.delScan) self.RemoteScan.triggered.connect(self.RS) self.login_ID.triggered.connect(self.login) self.add_plan.triggered.connect(self.append_plan) self.add_report.triggered.connect(self.append_report) self.plan.triggered.connect(self.run_plan) self.del_plan.triggered.connect(self.remove_plan) self.del_report.triggered.connect(self.remove_report) self.report.triggered.connect(self.run_report) self.setting.triggered.connect(self.run_setting) self.delbtn.triggered.connect(self.delsetting)
def __init__(self, world, x=0.0, y=0.0, material=None): self.world = world self.position = Vector(x, y) self.previous = Vector(x, y) if material == None: self.material = Material() else: self.material = material
def chooseMat(self, index): if index < 0: return import Material name = self.pathList[index] self.obj.Material = Material.importFCMat(str(name)) self.form.comboBox_MaterialsInDir.setCurrentIndex(index) self.set_mat_params_in_combo_box(self.obj.Material) self.print_mat_data(self.obj.Material)
def write(filename, dictionary): "writes the given dictionary to the given file" # sort the data into sections contents = [] tree = Material.getMaterialAttributeStructure() MatPropDict = tree.getroot() for group in MatPropDict.getchildren(): groupName = group.attrib['Name'] contents.append({"keyname": groupName}) if groupName == "Meta": header = contents[-1] elif groupName == "User defined": user = contents[-1] for proper in group.getchildren(): properName = proper.attrib['Name'] contents[-1][properName] = "" for k, i in dictionary.iteritems(): found = False for group in contents: if not found: if k in group.keys(): group[k] = i found = True if not found: user[k] = i # write header rev = FreeCAD.ConfigGet("BuildVersionMajor") + "." + FreeCAD.ConfigGet( "BuildVersionMinor") + " " + FreeCAD.ConfigGet("BuildRevision") if isinstance(filename, unicode): import sys filename = filename.encode(sys.getfilesystemencoding()) print(filename) f = pythonopen(filename, "wb") f.write("; " + header["CardName"].encode("utf8") + "\n") f.write("; " + header["AuthorAndLicense"].encode("utf8") + "\n") f.write("; file produced by FreeCAD " + rev + "\n") f.write( "; information about the content of this card can be found here:\n") f.write("; http://www.freecadweb.org/wiki/index.php?title=Material\n") f.write("\n") if header["Source"]: f.write("; source of the data provided in this card:\n") f.write("; " + header["Source"].encode("utf8") + "\n") f.write("\n") # write sections for s in contents: if s["keyname"] != "Meta": if len(s) > 1: # if the section has no contents, we don't write it f.write("[" + s["keyname"] + "]\n") for k, i in s.items(): if (k != "keyname" and i != '') or k == "Name": # use only keys which are not empty and the name even if empty f.write(k + "=" + i.encode('utf-8') + "\n") f.write("\n") f.close()
def getMaterial(self): returnValue = libpanda._inPkJyoKxv4(self.this) import Material returnObject = Material.Material(None) returnObject.this = returnValue if returnObject.this == 0: return None returnObject.userManagesMemory = 1 return returnObject.setPointer()
def update_strain(self): self.a_parallel = self.subM.parm['alc'] self.mtrlAlloys = [ Material.Alloy(self.materials[idx], self.moleFracs[idx], self.Temperature) for idx in range(len(self.materials)) ] for al in self.mtrlAlloys: al.set_strain(self.a_parallel)
def getMaterial(temp): returnValue = libpanda._inPMAKPNuX5(temp.this) import Material returnObject = Material.Material(None) returnObject.this = returnValue if returnObject.this == 0: return None returnObject.userManagesMemory = 1 return returnObject.setPointer() return
def write(filename, dictionary): "writes the given dictionary to the given file" # sort the data into sections contents = [] tree = Material.getMaterialAttributeStructure() MatPropDict = tree.getroot() for group in MatPropDict.getchildren(): groupName = group.attrib['Name'] contents.append({"keyname": groupName}) if groupName == "Meta": header = contents[-1] elif groupName == "User defined": user = contents[-1] for proper in group.getchildren(): properName = proper.attrib['Name'] contents[-1][properName] = "" for k, i in dictionary.iteritems(): found = False for group in contents: if not found: if k in group.keys(): group[k] = i found = True if not found: user[k] = i # write header rev = FreeCAD.ConfigGet("BuildVersionMajor") + "." + FreeCAD.ConfigGet("BuildVersionMinor") + " " + FreeCAD.ConfigGet("BuildRevision") if isinstance(filename, unicode): import sys filename = filename.encode(sys.getfilesystemencoding()) print(filename) f = pythonopen(filename, "wb") f.write("; " + header["CardName"].encode("utf8") + "\n") f.write("; " + header["AuthorAndLicense"].encode("utf8") + "\n") f.write("; file produced by FreeCAD " + rev + "\n") f.write("; information about the content of this card can be found here:\n") f.write("; http://www.freecadweb.org/wiki/index.php?title=Material\n") f.write("\n") if header["Source"]: f.write("; source of the data provided in this card:\n") f.write("; " + header["Source"].encode("utf8") + "\n") f.write("\n") # write sections for s in contents: if s["keyname"] != "Meta": if len(s) > 1: # if the section has no contents, we don't write it f.write("[" + s["keyname"] + "]\n") for k, i in s.items(): if (k != "keyname" and i != '') or k == "Name": # use only keys which are not empty and the name even if empty f.write(k + "=" + i.encode('utf-8') + "\n") f.write("\n") f.close()
def chooseMat(self,index): if index == 0:return import Material print index name = self.pathList[index-1] print 'Import ', str(name) self.obj.Material = Material.importFCMat(str(name)) print self.obj.Material self.transferFrom()
def add_mat_dir(self, mat_dir, icon): import glob import os import Material mat_file_extension = ".FCMat" ext_len = len(mat_file_extension) dir_path_list = glob.glob(mat_dir + '/*' + mat_file_extension) self.pathList = self.pathList + dir_path_list for a_path in dir_path_list: material_name = os.path.basename(a_path[:-ext_len]) self.form.cb_materials.addItem(QtGui.QIcon(icon), material_name, a_path) self.materials[a_path] = Material.importFCMat(a_path)
def set_mtrl(self, n, mtrl=None, moleFrac=None): """Set material[n] to new material (mtrl) and/or moleFrac""" if mtrl == None and moleFrac == None: raise Exception("Nothing changed") if mtrl == None: mtrl = self.materials[n] if moleFrac == None: moleFrac = self.moleFracs[n] self.moleFracs[n] = moleFrac self.materials[n] = mtrl self.mtrlAlloys[n] = Material.Alloy(mtrl, moleFrac, self.Temperature) self.mtrlAlloys[n].set_strain(self.a_parallel)
def create(params): samplertype = params['sampler'] samplenum = params['num_samples'] sampler = eval('%s(%d)' % (samplertype, samplenum)) shadow = False if 'shadow' in params: shadow = params['shadow'] == 1 if 'shader' in params: params['shader'] = Res.combine_res_path(params['shader']) mat = Material(params["shader"], params["shader_params"]) # if 'shader_params' in params: # for p in params["shader_params"]: # mat.set_param(p, params["shader_params"][p]) return EnvironmentLight(sampler, shadow, mat)
def addMatDir(mat_dir, materials): import glob import os import Material mat_file_extension = ".FCMat" ext_len = len(mat_file_extension) dir_path_list = glob.glob(mat_dir + '/*' + mat_file_extension) material_name_path_list = [] for a_path in dir_path_list: material_name = os.path.basename(a_path[:-ext_len]) materials[a_path] = Material.importFCMat(a_path) material_name_path_list.append([material_name, a_path]) material_name_path_list.sort() return material_name_path_list
def add_cards_from_a_dir(self, mat_dir, icon): import glob import os import Material mat_file_extension = ".FCMat" ext_len = len(mat_file_extension) dir_path_list = glob.glob(mat_dir + '/*' + mat_file_extension) self.pathList = self.pathList + dir_path_list card_name_list = [] for a_path in dir_path_list: card_name = os.path.basename(a_path[:-ext_len]) self.materials[a_path] = Material.importFCMat(a_path) card_name_list.append([card_name, a_path]) card_name_list.sort() for mat in card_name_list: self.parameterWidget.cb_materials.addItem(QtGui.QIcon(icon), mat[0], mat[1])
def add_mat_dir(self, mat_dir, icon): import glob import os import Material mat_file_extension = ".FCMat" ext_len = len(mat_file_extension) dir_path_list = glob.glob(mat_dir + '/*' + mat_file_extension) self.pathList = self.pathList + dir_path_list material_name_list = [] for a_path in dir_path_list: material_name = os.path.basename(a_path[:-ext_len]) self.materials[a_path] = Material.importFCMat(a_path) material_name_list.append([material_name, a_path]) material_name_list.sort() for mat in material_name_list: self.form.cb_materials.addItem(QtGui.QIcon(icon), mat[0], mat[1])
def add_mat_dir(self, mat_dir, icon): import glob import os import Material mat_file_extension = ".FCMat" ext_len = len(mat_file_extension) dir_path_list = glob.glob(mat_dir + "/*" + mat_file_extension) self.pathList = self.pathList + dir_path_list material_name_list = [] for a_path in dir_path_list: material_name = os.path.basename(a_path[:-ext_len]) self.materials[a_path] = Material.importFCMat(a_path) material_name_list.append([material_name, a_path]) material_name_list.sort() for mat in material_name_list: self.form.cb_materials.addItem(QtGui.QIcon(icon), mat[0], mat[1])
def get_material(self): ''' Build material instance from material input cells ''' # initiate material instance Mat = Material.MatProp() # getting the ext inputs or overwriting bad content <-- OVERWRITES SHOULD HAPPEN ON CHANGED-SIGNAL obj_list = [ 'f_ck', 'E_cm', 'f_yk', 'E_s', 'alpha_cc', 'gamma_c', 'gamma_s' ] for string in obj_list: # get e.g. obj = self.lineEdit_f_ck obj = getattr(self, 'lineEdit_' + string) value = float(obj.text()) # convert item text to float setattr( Mat, string, value ) # Send input value to class <-- should use setter-method Mat.update_strengths( ) # need to update as f_ck attribute could have been changed # set combobox selections (must be after strength update as it updates the stiffnesses) conc_method = self.comboBox_concrete.currentText() reinf_method = self.comboBox_reinf.currentText() Mat.set_methods(conc_method, reinf_method) # Mat.set_nu_method = self.comboBox_nu.currentText() # check if stiffness is assignable and update window accordingly assignable, E_cm = Mat.is_conc_stiffness_assignable() if not assignable: self.lineEdit_E_cm.setDisabled(True) # self.stored_E_cm = self.lineEdit_E_cm.text() self.lineEdit_E_cm.setText(str(round(E_cm, 4))) elif not self.lineEdit_E_cm.isEnabled(): E_cm = Material.MatProp.E_cm # load class default E_cm Mat.E_cm = E_cm self.lineEdit_E_cm.setText(str(E_cm)) self.lineEdit_E_cm.setDisabled(False) return Mat
def parseMtl(fname, mtls, pfx): with open(os.path.join(pfx, fname)) as fp: for line in fp: line = line.strip() lst = line.split(" ", 1) if lst[0] == "newmtl": curr = lst[1] mtls[curr] = Material() elif lst[0] == "Kd": mtls[curr].Kd = lst[1] elif lst[0] == "Ns": mtls[curr].shininess = lst[1] elif lst[0] == "Ks": mtls[curr].specular = lst[1] elif lst[0] == "map_Kd": mtls[curr].map_Kd = lst[1]
def material_editingFinished(self): ''' This method is executed when a material input is finished editing. Thorough check of all material inputs + resets invalid inputs ''' # getting the ext inputs or overwriting bad content string_list = [ 'f_ck', 'E_cm', 'f_yk', 'E_s', 'alpha_cc', 'gamma_c', 'gamma_s' ] # get e.g. obj = self.lineEdit_f_ck obj_list = [getattr(self, 'lineEdit_' + s) for s in string_list] # changing focus to another tracked input yields double exec # All objects are therefore initially blocked for obj in obj_list: obj.blockSignals(True) for obj, string in zip(obj_list, string_list): try: value = float(obj.text()) # convert item text to float if value <= 0: raise ValueError # setattr(Mat, string, value) # Send input value to class except Exception as e: self.show_msg_box([ 'Material input error', 'Input value "{}" for {} is not valid. {} returned to default value.' .format(obj.text(), string, string) ]) Mat = Material.MatProp() value = getattr( Mat, string) # Get default value from material class obj.setText(str(value)) # Replace bad item content self.material_plot() # plot default value for obj in obj_list: obj.blockSignals(False)
def __init__(self, *args): self.objects = {None: []} self.textures = {} self.gl_textures = {} self.materials = {} self.lights = [] self.options = SceneOptions() # apply default options self.materials[None] = Material() # setup default material self.Add(args) if len(self.lights) == 0: # add default light self.Add( Light(type=POINT).Move(*(self.options.size, ) * 3).Name('DefaultLight')) if not self.ambient_light: self.Add( Light(type=AMBIENT, intensity=self.options.ambient_intensity).Name( 'DefaultAmbientLight'))
def GetMaterial(name): mat = _MaterialManager.Instance.GetByName(name) if mat is not None: return Material._ExistingMaterial(mat) return None
def test_AlGaAs(self): Material.main("AlGaAs")
def saveMat(self): self.transferTo() filename = QtGui.QFileDialog.getSaveFileName(None, 'Save Material file file',self.params.GetString("MaterialDir",'/'),'FreeCAD material file (*.FCMat)') if(filename): import Material Material.exportFCMat(filename,self.obj.Material)
mesh_width = int(a) elif o in ("-h", "--mesh_height"): mesh_height = int(a) elif o in ("-c", "--cell_size"): cell_size = int(a) elif o in ("-i", "--iterations"): iterations = int(a) else: assert False, "unhandled option" # create mesh mesh = Mesh([cell_size, cell_size], [cell_size]) # create fuel fuel = Material(2, "fuel") fuel.setSigmaA([0.005, 0.10]) fuel.setD([1.5, 0.40]) fuel.setNuSigmaF([0.005, 0.15]) fuel.setChi([1.0, 0.0]) fuel.setSigmaS(np.array([[0.0, 0.02], [0.0, 0.0]])) # create fuel moderator = Material(2, "moderator") moderator.setSigmaA([0.0, 0.01]) moderator.setD([1.5, 0.20]) moderator.setSigmaS(np.array([[0.0, 0.025], [0.0, 0.0]])) if solve_method == "NEM4": order = 4 else:
def GetMaterial(name): mat = _MaterialManager.Instance.GetByName(name) if mat is not None: return Material._ExistingMaterial(mat) return None
def write(filename, dictionary, write_group_section=True): "writes the given dictionary to the given file" # sort the data into sections contents = [] tree = Material.getMaterialAttributeStructure() MatPropDict = tree.getroot() for group in MatPropDict.getchildren(): groupName = group.attrib['Name'] contents.append({"keyname": groupName}) if groupName == "Meta": header = contents[-1] elif groupName == "User defined": user = contents[-1] for proper in group.getchildren(): properName = proper.attrib['Name'] contents[-1][properName] = '' for k, i in dictionary.items(): found = False for group in contents: if not found: if k in group.keys(): group[k] = i found = True if not found: user[k] = i # delete empty properties for group in contents: for k in list(group.keys()): # iterating over a dict and changing it is not allowed, thus we iterate over a list of the keys if group[k] == '': del group[k] # card writer rev = FreeCAD.ConfigGet("BuildVersionMajor") + "." + FreeCAD.ConfigGet("BuildVersionMinor") + "." + FreeCAD.ConfigGet("BuildRevision") if isinstance(filename, unicode): if sys.version_info.major < 3: filename = filename.encode(sys.getfilesystemencoding()) # print(filename) card_name_file = os.path.splitext(os.path.basename(filename))[0] # print(card_name_file) f = pythonopen(filename, "w") # write header # first five lines are the same in any card file, see comment above read def if header["CardName"] != card_name_file: FreeCAD.Console.PrintMessage("File CardName is used: " + card_name_file + " \n") # CardName is the MatCard file name if sys.version_info.major >= 3: f.write("; " + card_name_file + "\n") f.write("; " + header["AuthorAndLicense"] + "\n") else: f.write("; " + header["CardName"].encode("utf8") + "\n") f.write("; " + header["AuthorAndLicense"].encode("utf8") + "\n") f.write("; information about the content of such cards can be found on the wiki:\n") f.write("; https://www.freecadweb.org/wiki/Material\n") f.write("; file created by FreeCAD" + rev + "\n") # write sections # write standard FCMat section if write group section parameter is set to False if write_group_section is False: f.write("\n[FCMat]\n") for s in contents: if s["keyname"] != "Meta": # if the section has no contents, we don't write it if len(s) > 1: # only write group section if write group section parameter is set to True if write_group_section is True: f.write("\n[" + s["keyname"] + "]\n") for k, i in s.items(): if (k != "keyname" and i != '') or k == "Name": # use only keys which are not empty and the name even if empty if sys.version_info.major >= 3: f.write(k + " = " + i + "\n") else: f.write(k + " = " + i.encode('utf-8') + "\n") f.close()
Created on Thu Jan 05 11:50:47 2017 @author: j.Sun """ from Node import * from Material import * from Data import * from Constants import * from Work import * from Plot import * #============================================================================== # material #============================================================================== material = Material() material.setName(name='IN718') material.setTemperature(temperature=650.0) material.setMonotonic(youngs_modulus=167100.0,poisson_ratio=0.2886,yield_stress=1064.0) material.setCyclicAxial(sigma_f=1034.0,b=-0.04486,epsilon_f=0.11499,c=-0.52436) material.setCyclicTorsion(tau_f=1034.0/np.sqrt(3),b0=-0.04486,gamma_f=0.11499*np.sqrt(3),c0=-0.52436) material.show() #============================================================================== # job #============================================================================== name = '7037' experiment_log = ExperimentLog(ExperimentDirectory + 'Inconel718_test_log.csv') experiment_log.find(name) sim = SimulationData(r'F:\Temp\IN7182\7037\7037.csv')
# from scipy.special import erf # import scipy.optimize as op import pandas as pd import Stack as st import Stefan as ste import Material as ma """ Physical Parameters """ date = '29-03-2018' serie = 9 folder = '/Users/eablonet/Documents/0_phd/4_reports/reu_26_03_2019/images/' # ice ice = ma.Ice() rho = ice.get_rho() k = ice.get_k() cp = ice.get_cp() Lf = 333500 # water (check values) water = ma.Water() rho_l = water.get_rho() k_l = water.get_k() cp_l = water.get_cp() # solver manip_data = pd.read_csv('manips.csv', skiprows=[0, 2], decimal=",") # manip_data.info() s = st.Stack()
if o in ("-t", "--tolerance"): tol = float(a) elif o in ("-m", "--method"): solve_method = a elif o in ("-i", "--iterations"): iterations = int(a) else: assert False, "unhandled option" # create mesh mesh = Mesh([cell_size,cell_size,cell_size,cell_size,cell_size,cell_size,cell_size,cell_size,cell_size,cell_size,cell_size], [cell_size,cell_size,cell_size,cell_size,cell_size,cell_size,cell_size,cell_size,cell_size,cell_size,cell_size]) # create fuel 1 blade in fuel1bin = Material(2, 'fuel 1 blade in') fuel1bin.setSigmaA([0.0083775, 0.1003211]) fuel1bin.setD([1.255, 0.211]) fuel1bin.setNuSigmaF([0.004602, 0.1091]) fuel1bin.setChi([1.0, 0.0]) fuel1bin.setSigmaS(np.array([[0.0, 0.02533],[0.0, 0.0]])) # create fuel 1 blade out fuel1bo = Material(2, 'fuel 1 blade out') fuel1bo.setSigmaA([0.0073078, 0.07048902]) fuel1bo.setD([1.268, 0.1902]) fuel1bo.setNuSigmaF([0.004609, 0.08675]) fuel1bo.setChi([1.0, 0.0]) fuel1bo.setSigmaS(np.array([[0.0, 0.02767],[0.0, 0.0]])) # create fuel 2 blade in
def __init__(self): self.transform = Matrix.IdentityMatrix(4) self.material = Material.Material()
def main(): start = time.time() # set default values tol = 1.e-8 cell_size = 10.0 solve_method = 'NEM4' iterations = 100 # create mesh mesh = Mesh([cell_size,cell_size], [cell_size]) # create fuel fuel = Material(2, 'fuel') fuel.setSigmaA([0.005, 0.10]) fuel.setD([1.5, 0.40]) fuel.setNuSigmaF([0.005, 0.15]) fuel.setChi([1.0, 0.0]) fuel.setSigmaS(np.array([[0.0, 0.02],[0.0, 0.0]])) # create fuel moderator = Material(2, 'moderator') moderator.setSigmaA([0.0, 0.01]) moderator.setD([1.5, 0.20]) moderator.setSigmaS(np.array([[0.0, 0.025],[0.0, 0.0]])) if solve_method == 'NEM4': order = 4 else: order = 2 # add materials to cells mesh.cells[0].setMaterial(fuel, order) mesh.cells[1].setMaterial(moderator, order) # mesh = mesh.refineMesh(.1) mesh.makeSurfaces() # plot the mesh pttr.plotMesh(mesh) # create solver solver = Solver(mesh, solve_method) # solve the matrix problem to get flux profile and keff solver.solve(tol, iterations) # plot the flux pttr.plotFlux(solver) pttr.plotCellFlux(solver) pttr.plotCurrent(solver) stop = time.time() print 'Ran time ' + str(stop-start)[0:5] + ' seconds' print '----------------------------------------------------------------------'
def test_Alloy_AlGaAs(self): algaas = Material.Alloy("AlGaAs", 0.0) # so that is pure GaAs gaas = Material.Material("GaAs") # self.assertEqual(gaas.parm.pop("Crystal"), "ZincBlende") for key in gaas.parm: self.assertAlmostEqual(algaas.parm[key], gaas.parm[key])
# For when this script is excetuted on its own if __name__ == '__main__': # if we're running file directly and not importing it # Define Geometry X = [-1500, 1500, 1500, -1500] # X-coordinates Y = [1500, 1500, -2000, -2000] # Y-coordinates T = [200, 200, 200, 200] # Wall thickness rho_long = [0.02, 0.02, 0.02, 0.02] # Reinforcement ratio Geometry = {'X': X, 'Y': Y, 'T': T, 'rho_long': rho_long} Geometry['wallNodeN'] = 10 # Define sectional forces N = -17000 My = 50000 Mz = 00000 Vy = 0 Vz = 2000 T = 0 SF = SectionForces.SectionForces(N, My, Mz, Vy, Vz, T) # Initiate Material class Mat = Material.MatProp() # Call SLS analysis Res = SLS_analysis(Geometry, SF, Mat) # Call ULS analysis Res = ULS_analysis(Geometry, SF, Mat) # print(Res.plot_names)
def test_zero_strain(self): gaas = Material.Material("GaAs") gaas.set_strain(gaas.parm["alc"]) self.assertAlmostEqual(gaas.a_perp, gaas.parm["alc"])
def write(filename, dictionary): "writes the given dictionary to the given file" # sort the data into sections contents = [] tree = Material.getMaterialAttributeStructure() MatPropDict = tree.getroot() for group in MatPropDict.getchildren(): groupName = group.attrib['Name'] contents.append({"keyname": groupName}) if groupName == "Meta": header = contents[-1] elif groupName == "User defined": user = contents[-1] for proper in group.getchildren(): properName = proper.attrib['Name'] contents[-1][properName] = '' for k, i in dictionary.items(): found = False for group in contents: if not found: if k in group.keys(): group[k] = i found = True if not found: user[k] = i # delete empty properties for group in contents: for k in list( group.keys() ): # iterating over a dict and changing it is not allowed, thus we iterate over a list of the keys if group[k] == '': del group[k] # card writer rev = FreeCAD.ConfigGet("BuildVersionMajor") + "." + FreeCAD.ConfigGet( "BuildVersionMinor") + "." + FreeCAD.ConfigGet("BuildRevision") if isinstance(filename, unicode): if sys.version_info.major < 3: filename = filename.encode(sys.getfilesystemencoding()) # print(filename) card_name_file = os.path.splitext(os.path.basename(filename))[0] # print(card_name_file) f = pythonopen(filename, "w") # write header # first five lines are the same in any card file, see comment above read def if header["CardName"] != card_name_file: FreeCAD.Console.PrintMessage( "File CardName is used: " + card_name_file + " \n") # CardName is the MatCard file name if sys.version_info.major >= 3: f.write("; " + card_name_file + "\n") f.write("; " + header["AuthorAndLicense"] + "\n") else: f.write("; " + header["CardName"].encode("utf8") + "\n") f.write("; " + header["AuthorAndLicense"].encode("utf8") + "\n") f.write( "; information about the content of such cards you can find here:\n") f.write("; http://www.freecadweb.org/wiki/index.php?title=Material\n") f.write("; file produced by FreeCAD" + rev + "\n") f.write("\n") # write sections for s in contents: if s["keyname"] != "Meta": if len(s) > 1: # if the section has no contents, we don't write it f.write("[" + s["keyname"] + "]\n") for k, i in s.items(): if (k != "keyname" and i != '') or k == "Name": # use only keys which are not empty and the name even if empty if sys.version_info.major >= 3: f.write(k + "=" + i + "\n") else: f.write(k + "=" + i.encode('utf-8') + "\n") f.write("\n") f.close()
def test_GaAs(self): Material.main("GaAs")