Commit 4681357e authored by Daniel Brown's avatar Daniel Brown
Browse files

changing ROMHOM output file

parent 426c99be
...@@ -143,28 +143,30 @@ class surfacemap(object): ...@@ -143,28 +143,30 @@ class surfacemap(object):
raise BasePyKatException("Map type needs handling") raise BasePyKatException("Map type needs handling")
def generateROMWeights(self, isModeMatched=True, verbose=False, interpolate=False, tolerance = 1e-12, sigma = 1, sort=False, greedyfile=None): def generateROMWeights(self, isModeMatched=True, verbose=False, interpolate=False, interpolate_N=None, tolerance = 1e-12, sigma = 1, sort=False, greedyfile=None):
if interpolate: if interpolate:
from scipy.interpolate import interp2d from scipy.interpolate import interp2d
import numpy as np import numpy as np
D = interp2d(self.x, self.y, self.data, fill_value=0) D = interp2d(self.x, self.y, self.data, fill_value=0)
if interpolate_N is None:
interpolate_N = (self.size[0], self.size[1])
# only want even number of data points spread equally # only want even number of data points spread equally
# about the axes # about the axes
if self.size[0] % 2 == 0: if interpolate_N[0] % 2 == 0:
Nx = self.size[0] Nx = interpolate_N[0]
else: else:
Nx = self.size[0]-1 Nx = interpolate_N[0]-1
if self.size[1] % 2 == 0: if interpolate_N[1] % 2 == 0:
Ny = self.size[1] Ny = interpolate_N[1]
else: else:
Ny = self.size[1]-1 Ny = interpolate_N[1]-1
nx = np.linspace(min(self.x), max(self.x), Nx) nx = np.linspace(min(self.x), max(self.x), interpolate_N[0])
ny = np.linspace(min(self.y), max(self.y), Ny) ny = np.linspace(min(self.y), max(self.y), interpolate_N[1])
data = D(nx-self.offset[0], ny-self.offset[0]) data = D(nx-self.offset[0], ny-self.offset[0])
......
...@@ -28,37 +28,48 @@ class ROMWeights: ...@@ -28,37 +28,48 @@ class ROMWeights:
self.limits = limits self.limits = limits
def writeToFile(self, filename): def writeToFile(self, filename):
f = open(filename, 'w+') """
Writes this map's ROM weights to a file
that can be used with Finesse. The filename
is appended with '.rom' internally.
"""
f = open(filename + ".rom", 'w+')
f.write("zmin=%16.16e\n" % self.limits.zmin)
f.write("zmax=%16.16e\n" % self.limits.zmax)
f.write("w0min=%16.16e\n" % self.limits.w0min)
f.write("w0max=%16.16e\n" % self.limits.w0max)
f.write("maxorder=%i\n" % self.limits.max_order)
f.write("xnodes=%i\n" % len(self.EI["xm"].nodes))
for v in self.EI["xm"].nodes.flatten():
f.write("%s\n" % repr(float(v)))
f.write(repr(self.limits) + "\n") f.write("ynodes=%i\n" % len(self.EI["ym"].nodes))
for v in self.EI["ym"].nodes.flatten():
f.write("%s\n" % repr(float(v)))
f.write(repr(self.w_ij_Q1.shape) + "\n") f.write(repr(self.w_ij_Q1.shape) + "\n")
for v in self.w_ij_Q1.flatten(): for v in self.w_ij_Q1.flatten():
f.write("%s " % repr(complex(v))[1:-1]) f.write("%s\n" % repr(complex(v))[1:-1])
f.write("\n")
f.write(repr(self.w_ij_Q2.shape) + "\n") f.write(repr(self.w_ij_Q2.shape) + "\n")
for v in self.w_ij_Q2.flatten(): for v in self.w_ij_Q2.flatten():
f.write("%s " % repr(complex(v))[1:-1]) f.write("%s\n" % repr(complex(v))[1:-1])
f.write("\n")
f.write(repr(self.w_ij_Q3.shape) + "\n") f.write(repr(self.w_ij_Q3.shape) + "\n")
for v in self.w_ij_Q3.flatten(): for v in self.w_ij_Q3.flatten():
f.write("%s " % repr(complex(v))[1:-1]) f.write("%s\n" % repr(complex(v))[1:-1])
f.write("\n")
f.write(repr(self.w_ij_Q4.shape) + "\n") f.write(repr(self.w_ij_Q4.shape) + "\n")
for v in self.w_ij_Q4.flatten(): for v in self.w_ij_Q4.flatten():
f.write("%s " % repr(complex(v))[1:-1]) f.write("%s\n" % repr(complex(v))[1:-1])
f.write("\n")
f.close() f.close()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment