Exemplo n.º 1
0
    def load(self, rec_file):
        """Loads stored data to instantiate a surrogate model.

        Parameters
        ----------
        rec_file : str
            Name of the file in `latom.data.smt` where the surrogate model is stored

        """

        self.d = load(self.abs_path(rec_file))
        self.limits = self.d['limits']
        self.x_samp = self.d['x_samp']
        self.m_prop = self.d['m_prop']
        self.failures = self.d['failures']
Exemplo n.º 2
0
    def load(self, rec_file):
        """Loads stored data to instantiate a meta model.

        Parameters
        ----------
        rec_file : str
            Name of the file in `latom.data.metamodels` where the meta model is stored

        """

        self.d = load(self.abs_path(rec_file))
        self.twr = self.d['twr']
        self.Isp = self.d['Isp']
        self.m_prop = self.d['m_prop']
        self.failures = self.d['failures']
Exemplo n.º 3
0
import numpy as np

from latom.utils.pickle_utils import load, save
from latom.data.metamodels.data_mm import dirname_metamodels
from latom.plots.response_surfaces import RespSurf

plot = 'mp'  # 'mp' to plot the propellant fraction, 'en' to plot the spacecraft energy
fid = None  # 'llo2apo_lin_19_12_390-500.pkl'  # filename for adjusted solution
direction = 1  # stack Isp (columns, 1) or thrust/weight ratios (rows, 0)

# load raw solutions
fid1 = '/'.join([dirname_metamodels, 'llo2apo_lin_19_6_390-440.pkl'])
fid2 = '/'.join([dirname_metamodels, 'tests/llo2apo_mm_lin450-500.pkl'])
d1 = load(fid1)
d2 = load(fid2)

# stack solutions
if np.isclose(direction, 0):  # same Isp bounds and step

    m_prop = np.vstack((d1['m_prop'], d2['m_prop']))
    energy = np.vstack((d1['energy'], d2['energy']))
    failures = np.vstack((d1['failures'], d2['failures']))

    twr = np.hstack((d1['twr'], d2['twr']))
    isp = d1['Isp']

elif np.isclose(direction, 1):  # same thrust/weight ratio bounds and step

    m_prop = np.hstack((d1['m_prop'], d2['m_prop']))
    energy = np.hstack((d1['energy'], d2['energy']))
    failures = np.hstack((d1['failures'], d2['failures']))
Exemplo n.º 4
0
                           extrapolate=extrapolate,
                           method=im_mm,
                           training_data_gradients=training_data_gradients,
                           vec_size=nb_points,
                           rec_file=fid_mm)

            # SurrogateModel instance(s)
            sm_lhs = SurrogateModel(tm_lhs, rec_file=fid_lhs)
            if fid_full is not None:
                sm_full = SurrogateModel(tm_full, rec_file=fid_full)
            else:
                sm_full = None

            # benchmark points
            if compute_err and (not solve):
                d = load(fid_real)
                isp = d['Isp']
                twr = d['twr']
            else:
                if sm_full is not None:
                    isp = generate_benchmark_points(mm.limits[0],
                                                    nb_points,
                                                    mm.Isp,
                                                    sm_lhs.x_samp[:, 0],
                                                    sm_full.x_samp[:, 0],
                                                    atol=1e-6)
                    twr = generate_benchmark_points(mm.limits[1],
                                                    nb_points,
                                                    mm.twr,
                                                    sm_lhs.x_samp[:, 1],
                                                    sm_full.x_samp[:, 1],
Exemplo n.º 5
0
from latom.utils.pickle_utils import load, save
from latom.data.continuation.data_continuation import dirname_continuation
from latom.data.metamodels.data_mm import dirname_metamodels
from latom.plots.response_surfaces import RespSurf

plot = 'mp'  # 'mp' to plot the propellant fraction, 'en' to plot the spacecraft energy
fid = None  # 'llo2apo_lin_005-05_250-330.pkl'  # filename for adjusted solution

en_threshold = -6e4  # spacecraft energy threshold
isp_lim = (0, None)  # new specific impulse limits
twr_lim = (2, None)  # new thrust/weight ratio limits

# load raw solution
fid_raw = '/'.join([dirname_metamodels, 'tests/llo2apo_mm_lin159.pkl'])
d = load(fid_raw)

# extract data from dictionary
isp_raw = np.reshape(d['Isp'], (1, np.size(d['Isp'])))
twr_raw = np.reshape(d['twr'], (np.size(d['twr']), 1))
m_prop_raw = d['m_prop']
energy_raw = d['energy']

# Isp and thrust/weight ratio matrices
isp_mat = np.ones(np.shape(energy_raw)) * isp_raw
twr_mat = np.ones(np.shape(energy_raw)) * twr_raw

# Isp and thrust/weight ratios for which the solution degenerated into a parabola
twr_fail = twr_mat[energy_raw > en_threshold]
isp_fail = isp_mat[energy_raw > -en_threshold]