def makeGeometry(gridWidth, gridHeight): delta = 1.0 gridWidth = gridWidth gridHeight = gridHeight rect = Rectangle(0, 0, gridWidth, gridHeight) g = Geometry(rect, delta) return g
def generate_dataset(count, trainingsSetGeometry, charges, label): #np.set_printoptions(threshold=np.nan) index = 0 # setup for finite differences rect = Rectangle(0.0, 0.0, trainingsSetGeometry.gridWidth, trainingsSetGeometry.gridHeight) delta = 1.0 g = Geometry(rect, delta) start = time.time() dataset = calculate_random_parameters(count, trainingsSetGeometry, chargesList=charges.chargesList, label=label) for dataElement in dataset: dataElement.calc_permittivity_matrix(64, 64, 32, 32) duration = time.time() - start print('Total duration for generating {0} dataset elements:{1}'.format( count, duration)) return dataset
def __init__(self, gridWidth, gridHeight): self.gridWidth = gridWidth self.gridHeight = gridHeight self.delta = 1.0 self.rect = Rectangle(0, 0, gridWidth, gridHeight) self.geometry = Geometry(self.rect, self.delta) self.boundaryCondition = RectangularBoundaryCondition(self.geometry) self.auxiliaryFunctions = {}
def make_charges(trainingsSetGeometry): rect = Rectangle(0.0, 0.0, trainingsSetGeometry.gridWidth, trainingsSetGeometry.gridHeight) delta = 1.0 g = Geometry(rect, delta) countCharges = 11 chargeValue = -10.0 yCoord = 20.0 xCoordLeft = rect.midX() - (trainingsSetGeometry.gridWidth - trainingsSetGeometry.innerGridWidth) / 2.0 xCoordRight = rect.midX() + (trainingsSetGeometry.gridWidth - trainingsSetGeometry.innerGridWidth) / 2.0 return make_charges_in_line(g, countCharges, chargeValue, xCoordLeft, yCoord, xCoordRight, yCoord)
def calcSolutions(inputDataSet): delta = 1.0 rect = Rectangle(0, 0, inputDataSet.geometry.gridWidth, inputDataSet.geometry.gridHeight) g = Geometry(rect, delta) boundaryCondition = RectangularBoundaryCondition(g) charges = load_chargedistribution(g, inputDataSet) index = 1 resultsSet = ResultsSet(label=inputDataSet.label) start = time.time() for dataElement in inputDataset: eps = generate_permittivity_function( dataElement.get_permittivity_matrix()) gridConfig = make_finite_differences_poisson_equation_in_matter(eps) #fdm3 = FiniteDifferencesMethod3(g, boundaryCondition, gridConfig, charges) #fdm3.solve() #fdm3.calcMetrices() fdm = FiniteDifferencesMethod4(g, boundaryCondition, gridConfig, charges) fdm.solve() #fdm.calcMetrices() #compareVectors(fdm3.bias, fdm.bias) #compareMatrices(fdm3.matrix, fdm.matrix.todense()) #resultsSet.add(fdm.results) resultsSet.add(fdm.values) #s = json.dumps(fdm.results.tolist()) #print(s) #s = generate_text_presentation(index, dataElement, fdm.values, fdm.error) index = index + 1 duration = time.time() - start print('Total duration for solving {0} PDEs lasted :{1}'.format( inputDataset.count(), duration)) return resultsSet
cmap=self.cmap) self.error_axes.set_title('Errors', fontsize=9) self.colorbar = fig.colorbar(im, ax=self.error_axes) if __name__ == '__main__': np.set_printoptions(threshold=np.nan) count = 60 index = 0 # setup for finite differences delta = 1.0 rect = Rectangle(0, 0, 64.0, 64.0) g = Geometry(rect, delta) boundaryCondition = RectangularBoundaryCondition(g) charges = make_charges_in_line(g, 11, -10.0, 16.0, 20.0, 48.0, 20.0) #charges = make_charges_in_line(g, 32, -10.0, 16.0, 20.0, 48.0, 20.0) # setup for plot fig = plt.figure() permittivity_data = load_test_set(count) permittivity_title = 'eps = {0}'.format( permittivity_data[0]['permittivities'][index]) permittivity_axes = fig.add_subplot(1, 3, 1) surface_axes = fig.add_subplot(1, 3, 2, projection='3d') error_axes = fig.add_subplot(1, 3, 3) def generate_finite_differences_solver(index):