The addResponses Method

In this example, the objective is to find a design such that the RMS values of displacement, velocity, and acceleration are minimized. The RMS signals are computed as:(1)
R 1 = 0 T x 2 d t R 2 = 0 T x ˙ 2 d t R 3 = 0 T x ¨ 2 d t MathType@MTEF@5@5@+= feaagKart1ev2aqatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbuLwBLn hiov2DGi1BTfMBaeXatLxBI9gBaerbd9wDYLwzYbItLDharqqtubsr 4rNCHbGeaGqiVu0Je9sqqrpepC0xbbL8F4rqqrFfpeea0xe9Lq=Jc9 vqaqpepm0xbba9pwe9Q8fs0=yqaqpepae9pg0FirpepeKkFr0xfr=x fr=xb9adbaqaaeGaciGaaiaabeqaamaabaabaaGceaqabeaaqqaaaa aaOpGqSvxza8qacaWGsbGaaGymaiabg2da9maapehabaGaamiEamaa CaaaleqabaGaaGOmaaaakiaadsgacaWG0baaleaacaaIWaaabaGaam ivaaqdcqGHRiI8aaGcbaGaamOuaiaaikdacqGH9aqpdaWdXbqaaiqa dIhagaGaamaaCaaaleqabaGaaGOmaaaakiaadsgacaWG0baaleaaca aIWaaabaGaamivaaqdcqGHRiI8aaGcpaqaa8qacaWGsbGaaG4maiab g2da9maapehabaGabmiEayaadaWaaWbaaSqabeaacaaIYaaaaOGaam izaiaadshaaSqaaiaaicdaaeaacaWGubaaniabgUIiYdaaaaa@5811@

Three responses of type RMS2 are created for defining these values. The objective to minimize the sum of these three responses (R1 + R2 + R3).

We also create a constraint (based on response type ResponseExpression) to make sure that the gain of PID controller would not increase infinitely. The constraint has the form:(2)
φ 1 k P : 2 k I 2 k D 2 < 0 MathType@MTEF@5@5@+= feaagKart1ev2aaatCvAUfeBSjuyZL2yd9gzLbvyNv2CaerbdfwBIj xAHbstHrhAaerbuLwBLnhiov2DGi1BTfMBaeXafv3ySLgzGmvETj2B Sbqefm0B1jxALjhiov2Daebbfv3ySLgzGueE0jxyaibaieYlf9irVe eu0dXdh9vqqj=hEeeu0xXdHaf9frFj0=OqFfea0dXdd9vqaq=JfrVk FHe9pgea0dXdar=Jb9hs0dXdbPYxe9vr0=vr0=vqpWqaciaacaWadm aadaGaciaaeeGabuaaaOaeeaaaaaa6dieB1vgapeqaaeXatLxBI9gB aGGbciab=z8aQjablYLiajaabgdacqGHsislcaqGRbWaa0baaSqaai aabcfacaGG6aaabaGaaeOmaaaakiabgkHiTiaabUgadaqhaaWcbaGa aeysaaqaaiaabkdaaaGccqGHsislcaqGRbWaa0baaSqaaiaabseaae aacaqGYaaaaOGaeyipaWJaaGimaaaa@54F1@

The addResponses method for this model is shown below:

def addResponse(self, time):
    """
    We minimize the influence of disturbance on the block
    R1: Integral(acceleration**2,time)
    R2: Integral(velocity**2,time)
    R3: Integral(Displacement**2,time)
    R4: Constraint (1 - kp**2 - ki**2 - kd**2 < 0)
    """
    # Define the desired profile
    zero_vector = [0.0 for i in time]
    targetValue = zip(time,zero_vector)

    # Measure the RMS acceleration deviation from desired
    expr = 'ACCZ({I},{J})'.format(I=self.block.cm.id, J=self.rm.id)
    self.R1 = RMS2 (
      label         ='acceleration',
      targetValue   = targetValue, 
      measuredValue = expr,
      )

    # Measure the RMS velocity deviation from desired
    expr = 'VZ({I},{J})'.format(I=self.block.cm.id,J=self.rm.id)
    self.R2 = RMS2 (
      label         = 'velocity',
      targetValue   = targetValue,
      measuredValue = expr,
      )

    # Measure the RMS displacement deviation from desired
    expr = 'DZ({I},{J})'.format(I=self.block.cm.id,J=self.rm.id)
    self.R3 = RMS2 (
      label         = 'displacement',
      targetValue   = targetValue, 
      measuredValue = expr,
      )

    # The constraint
    self.R4 = ResponseExpression(
      label='sum of squares',
      function = '1 - kp**2 - kd**2 - ki**2',
      symbols = ["kp", "kd", "ki"],
      variables = [self.dv_kp, self.dv_kd, self.dv_ki]
      )