diff --git a/tacs/caps2tacs/tacs_aim.py b/tacs/caps2tacs/tacs_aim.py index 97be4ddf5..764298066 100644 --- a/tacs/caps2tacs/tacs_aim.py +++ b/tacs/caps2tacs/tacs_aim.py @@ -187,13 +187,14 @@ def setup_aim( # link the egads aim to the tacs aim self.aim.input["Mesh"].link(self._mesh_aim.aim.output["Surface_Mesh"]) - # add the design variables to the DesignVariable and DesignVariableRelation properties + # Add the design variables to the DesignVariable and DesignVariableRelation properties + # for active variables only. DV_dict = {} - if len(self.thickness_variables) > 0: + if len(self.active_thickness_variables) > 0: self.aim.input.Design_Variable_Relation = { dv.name: dv.DVR_dictionary for dv in self._design_variables - if isinstance(dv, ThicknessVariable) + if isinstance(dv, ThicknessVariable) and dv._active } # register all thickness variables to each proc @@ -268,10 +269,17 @@ def variables(self) -> List[ShapeVariable or ThicknessVariable]: def shape_variables(self) -> List[ShapeVariable]: return [dv for dv in self.variables if isinstance(dv, ShapeVariable)] + @property + def active_thickness_variables(self) -> List[ThicknessVariable]: + """ + Return only active sorted thickness variables. + """ + return [dv for dv in self.thickness_variables if dv._active] + @property def thickness_variables(self) -> List[ThicknessVariable]: """ - return sorted thickness vars so that the TACS derivatives can be appropriately obtained + Return sorted thickness vars so that the TACS derivatives can be appropriately obtained. """ thick_var_names = [ dv.name for dv in self.variables if isinstance(dv, ThicknessVariable) @@ -362,13 +370,14 @@ def update_properties(self): dv, ThicknessVariable ): if property.caps_group == dv.caps_group: - property.membrane_thickness == dv.value + property.membrane_thickness = dv.value break # input new design var and property cards - self.aim.input.Design_Variable = { - dv.name: dv.DV_dictionary for dv in self._design_variables - } + if len([_ for _ in self._design_variables if _._active]) > 0: + self.aim.input.Design_Variable = { + dv.name: dv.DV_dictionary for dv in self._design_variables + } self.aim.input.Property = { prop.caps_group: prop.dictionary for prop in self._properties } diff --git a/tacs/caps2tacs/tacs_model.py b/tacs/caps2tacs/tacs_model.py index 384becf46..d47883bc7 100644 --- a/tacs/caps2tacs/tacs_model.py +++ b/tacs/caps2tacs/tacs_model.py @@ -281,8 +281,7 @@ def update_design(self, input_dict: dict = None): changed_design = True # update thickness prop cards in t - if self.tacs_aim.change_shape: - self.tacs_aim.update_properties() + self.tacs_aim.update_properties() # record whether the design has changed & first analysis flag as well if self._first_analysis: