Aviary icon indicating copy to clipboard operation
Aviary copied to clipboard

Dimensional mismatch in external engine deck creation due to updating the model length before entries are removed

Open jtang156 opened this issue 2 months ago • 1 comments

Description

self.model_length in EngineDeck._check_data is updated before a section in the same method which removes values in the engine deck data, causing a dimensional mismatch downstream when EngineDeck._count_data is called.

Updating the value after the section which removes negative thrust values should resolve the issue. A workaround is to set the ignore_negative_thrust to False, which bypasses the removal of entries in the engine deck.

Example

self.model_length = len(self.data[ALTITUDE])

    # check that all required variables are present in engine data
    if not self.required_variables.issubset(engine_variables):
        # gather all missing required variables
        missing_variables = set()
        for var in engine_variables:
            if var in self.required_variables:
                missing_variables.add(var)

        # if missing_variables is not empty
        if not missing_variables:
            raise UserWarning(
                f'Required variables {missing_variables} are missing from {self.error_message}'
            )

    # Set all unused variables to default value of zero
    for key in data:
        if not len(data[key]):
            data[key] = np.zeros(self.model_length)

    **# removes data points with negative thrust if requested
    if self.get_val(Aircraft.Engine.IGNORE_NEGATIVE_THRUST):
        keep_idx = np.where(data[THRUST] >= 0)
        for key in data:
            data[key] = data[key][keep_idx]**

Aviary Version

0.10.0-dev

Relevant environment information

No response

jtang156 avatar Oct 07 '25 18:10 jtang156

I moved around when model length is defined to hopefully avoid this issue: #923

jkirk5 avatar Nov 25 '25 19:11 jkirk5