# Design Variables and Limits

Design variables are used to define parametric models.

By changing the values for design variables in a model, you can change the model. An optimizer will change the values of the design variables for a model in its quest to find an optimum solution.

Every design variable has a value and upper/lower limits ( ${b}_{L}$ and ${b}_{U}$ ). The value of the design variable is used to define the model. The optimizer is restricted to keep the design variable between its upper and lower bounds when it is attempting to optimize model behavior.

Many of the attributes for MotionSolve modeling entities are “designable”. This means the value(s) of the attribute can be set to numeric expression(s) that contains references to design variables. A model can have any number of design variables.

The examples below demonstrate the use of design variables in MotionSolve.

## Example

Assume you want to create spherical Parts that are parameterized in terms of its radius and material density. Given a radius and density as input, the mass and inertia of the PART are to be automatically deduced and subsequently used in creating a PART. Here is how you could achieve this.

```
def sphere (r, rho, loc, label):
mass = (4/3) * math.pi * (r**3) * rho
ixx = iyy = izz = 0.5 * mass * r**2
sphere = Part (mass=mass, ip=[ixx,iyy,izz], label=label)
sphere.cm = Marker (part=sphere, qp=loc, label=label + ”_CM”)
return sphere
```

```
# Steel sphere of radius 100 mm
r1 = Dv (label=”Radius of sphere-1”, b=100, blimit=[90,110])
rho1 = Dv (label=”Density of Steel”, b=7.8E-6, blimit=[2E-6,9E-6])
loc1 = [0,10,-25]
sph1 = sphere (r1, rho1, loc1, "Steel-Sphere")
```

```
# Aluminum sphere of radius 50 mm
r2 = Dv (label=”Radius of sphere-2”, b=50, blimit=[40,60])
rho2 = Dv (label=”Density of Aluminum”, b=2.7E-6, blimit=[2E-6,9E-6])
loc2 = [23, 34, 45]
sph2 = sphere (r2, rho2, loc2, "Aluminum-Sphere")
```

MotionSolve knows the mass and inertias of sph1 are dependent on r1
and rho. Similarly, it knows that the mass and inertias of sph2 are dependent on r2
and rho. Parts sph1 and sph2 are *designable*.

## Example

```
>>> #Create a designable Point
>>> px = Dv (label=”px”, b=1, blimit = [-2, +2])
>>> py = Dv (label=”py”, b=2, blimit = [-3, +3])
>>> pz = Dv (label=”pz”, b=3, blimit = [-4, +4])
>>> p = Point(px,py,pz)
>>> p
Point (1.0, 2.0, 3.0)
>>> #Create a Part
>>> b2 = Part (mass=1, ip=[1e-4,1e-4,1e-4])
>>> b2.cm = Marker (body=b2)
>>> #Create a MARKER m2 on PART b2: Its origin is at the designable point p
>>> m2 = Marker (body=b2, qp=p, zp=p+[0,0,1], label="Left end")
>>> m2.qp
Point (1.0, 2.0, 3.0)
```

The origin of MARKER m2 is specified in terms of the Point p which in turn is defined in terms of the design variables px, py and pz. The origin of MARKER m2 is designable.

For a complete list of entities and their attributes that are designable, please refer to the MSOLVE API Reference Guide. The Attribute Summary table for each entity specifies whether an attribute for an entity is designable or not.