\section{Introduction}

This model adds equations for a rigid body and constraints
to attach rigid bodies to other things.  The treatment is taken
from Chapter 12 of Zienkiewicz and Taylor~\cite{ZienTayl00b}.

The nodal variables are displacements in the $x$ and $y$ directions
and rotation about the $z$ axis.

\subsection{Interface}

\nwfilename{model-rigid.nw}\nwbegincode{1}\sublabel{NWmodE-modD-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-modD-1}}}\moddef{model-rigid.h~{\nwtagstyle{}\subpageref{NWmodE-modD-1}}}\endmoddef
#ifndef MODEL_RIGID_H
#define MODEL_RIGID_H

#include "modelmgr.h"

void model_rigid_register(model_mgr_t model_mgr);

#endif /* MODEL_RIGID_H */
\nwnotused{model-rigid.h}\nwendcode{}\nwbegindocs{2}\nwdocspar

\subsection{Rigid body equations}

% Equations of motion for the rigid body

The equations of motion for a rigid body with center of mass $R$
are the balance of linear and angular momentum:
\begin{eqnarray*}
  (m      r_{,t})_{,t} =   p_{,t} & = & \sum f_a \\
  (J \omega_{,t})_{,t} = \pi_{,t} & = & \sum (x_a - r) \times f_a
\end{eqnarray*}
Since we are working in two dimensions, $J$ is a scalar value
and not a 3-by-3 tensor, which makes life a little simpler.

\subsection{Rigid-flexible coupling}

% Lagrange multipliers

In general, our rigid bodies will be coupled to flexural elements
(beams).  We add the coupling by writing a set of constraint
equations that relate the rigid body displacements to the
displacements of attached nodes, and enforcing those constraints
via Lagrange multipliers.  For the moment, let $x$ be the vector
of unknowns for the flexible part, and $y$ be the vector of
unknowns for the rigid part.  Then we have two energy functionals
$I_1(x)$ and $I_2(y)$, and a coupling equation $C(x,y) = 0$.
According to Lagrange multipliers, to minimize $I_1 + I_2$
subject to the constraints, we should minimize
\[
  I(x, y, \lambda) = I_1(x) + I_2(y) + \lambda^T C(x,y)
\]

After we take variations of everything in sight, we end up with
the augmented residual equations
\[
  \begin{pmatrix}
    R_1(x) + \frac{\partial C}{\partial x}^T \lambda \\
    R_2(y) + \frac{\partial C}{\partial y}^T \lambda \\
    C(x, y)
  \end{pmatrix} = 0
\]
The tangent matrix is
\[
  \begin{pmatrix}
       K_1 &      0 & C_{,x}^T \\
         0 &    K_2 & C_{,y}^T \\
    C_{,x} & C_{,y} &        0
  \end{pmatrix}
\]

Note that the Lagrange multiplier variables $\lambda$ are purely
local, and could be eliminated on an element-by-element basis.
Right now, we leave them explicit in the system.

Let $u_1, u_2$ and $\theta$ be the displacement and rotation
nodal degrees of freedom for a beam node which is to be connected
to a rigid body.  The rigid body is described by the current position
of its center of mass ($r_1, r_2$) and the rotation matrix $Q(\omega)$
(rotation of $\omega$ in the plane).
If $R$ and $X$ are the reference positions for the rigid body
center of mass and the attached node, then
\[
  C =
  \begin{pmatrix}
    (r + Q(\omega) (X-R)) - x \\
    \omega - \theta
  \end{pmatrix} = 0
\]
There is one problem with these constraints -- the ``rotational''
parameter $\theta$ for the beam theory actually represents a
linearization, while $Q(\omega)$ is an honest rotation.  For
the moment, I cross my fingers and hope that the angles remain small
enough that replacing $\theta - \omega = O(\omega^2)$ with
$\theta - \omega = 0$ will not be too terrible.

\section{Implementation}

\nwenddocs{}\nwbegincode{3}\sublabel{NWmodE-modD.2-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-modD.2-1}}}\moddef{model-rigid.c~{\nwtagstyle{}\subpageref{NWmodE-modD.2-1}}}\endmoddef
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>

#include "model-rigid.h"
#include "affine.h"
#include "mesh.h"
#include "vars.h"
#include "assemble.h"
#include "netdraw.h"
#include "netout.h"

\LA{}types~{\nwtagstyle{}\subpageref{NWmodE-typ5-1}}\RA{}
\LA{}model functions~{\nwtagstyle{}\subpageref{NWmodE-modF-1}}\RA{}
\LA{}registration function~{\nwtagstyle{}\subpageref{NWmodE-regL-1}}\RA{}
\nwnotused{model-rigid.c}\nwendcode{}\nwbegindocs{4}\nwdocspar

\nwenddocs{}\nwbegincode{5}\sublabel{NWmodE-regL-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-regL-1}}}\moddef{registration function~{\nwtagstyle{}\subpageref{NWmodE-regL-1}}}\endmoddef
void model_rigid_register(model_mgr_t model_mgr)
\{
    model_element_t model;

    \LA{}register models~{\nwtagstyle{}\subpageref{NWmodE-regF-1}}\RA{}
\}
\nwused{\\{NWmodE-modD.2-1}}\nwendcode{}\nwbegindocs{6}\nwdocspar

\subsection{Rigid body model}

The user will eventually have to supply a mass and an inertia tensor,
but at the moment we just leave placeholders.  Note that the ``user''
here could well be a subnet or other higher-level abstraction.

\nwenddocs{}\nwbegincode{7}\sublabel{NWmodE-typ5-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-typ5-1}}}\moddef{types~{\nwtagstyle{}\subpageref{NWmodE-typ5-1}}}\endmoddef
typedef struct rigid_t \{
    element_t element;
    int node;
    int vars[3];
    double m;
    double J;
\} rigid_t;

\nwalsodefined{\\{NWmodE-typ5-2}}\nwused{\\{NWmodE-modD.2-1}}\nwendcode{}\nwbegindocs{8}\nwdocspar

\nwenddocs{}\nwbegincode{9}\sublabel{NWmodE-modF-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-modF-1}}}\moddef{model functions~{\nwtagstyle{}\subpageref{NWmodE-modF-1}}}\endmoddef
static element_t* rigid_init(mesh_t mesh, const char* model,
                        model_element_t* modelfunc)
\{
    rigid_t* self = (rigid_t*)
        mempool_cget(mesh_pool(mesh), sizeof(*self));

    self->element.data = self;
    self->element.model = modelfunc;

    if (mesh_num_param_nodes(mesh) != 1)
        mesh_error(mesh, "Incorrect number of nodes for rigid");
    self->node = mesh_param_node(mesh, 0);

    return &(self->element);
\}

\nwalsodefined{\\{NWmodE-modF-2}\\{NWmodE-modF-3}\\{NWmodE-modF-4}\\{NWmodE-modF-5}\\{NWmodE-modF-6}\\{NWmodE-modF-7}\\{NWmodE-modF-8}\\{NWmodE-modF-9}}\nwused{\\{NWmodE-modD.2-1}}\nwendcode{}\nwbegindocs{10}\nwdocspar

I am not sure whether giving the rigid body variables the same names
as the corresponding beam nodal variables is such a good idea.  But
I will do it anyway, at least for the moment.

\nwenddocs{}\nwbegincode{11}\sublabel{NWmodE-modF-2}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-modF-2}}}\moddef{model functions~{\nwtagstyle{}\subpageref{NWmodE-modF-1}}}\plusendmoddef
static void rigid_vars(void* pself, vars_mgr_t vars)
\{
    rigid_t* self = (rigid_t*) pself;

    self->vars[0] = vars_node(vars, self->node, "x");
    self->vars[1] = vars_node(vars, self->node, "y");
    self->vars[2] = vars_node(vars, self->node, "rz");
\}

\nwendcode{}\nwbegindocs{12}\nwdocspar

Once dynamics are ready, we'll have to make appropriate additions. %'
Until then, we just need an output function.

\nwenddocs{}\nwbegincode{13}\sublabel{NWmodE-modF-3}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-modF-3}}}\moddef{model functions~{\nwtagstyle{}\subpageref{NWmodE-modF-1}}}\plusendmoddef
static void rigid_output(void* pself, netout_t* netout)
\{
    rigid_t* self = (rigid_t*) pself;

    netout_string        (netout, "model",     "rigid");
    netout_int           (netout, "node",      self->node);
    netout_int_matrix    (netout, "vars",      self->vars, 1, 3);
\}

\nwendcode{}\nwbegindocs{14}\nwdocspar

\nwenddocs{}\nwbegincode{15}\sublabel{NWmodE-regF-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-regF-1}}}\moddef{register models~{\nwtagstyle{}\subpageref{NWmodE-regF-1}}}\endmoddef
memset(&model, 0, sizeof(model));
model.init    = rigid_init;
model.vars    = rigid_vars;
model.output  = rigid_output;
model_mgr_add_element(model_mgr, "rigid", &model);

\nwalsodefined{\\{NWmodE-regF-2}}\nwused{\\{NWmodE-regL-1}}\nwendcode{}\nwbegindocs{16}\nwdocspar

\subsection{Coupling model}

\nwenddocs{}\nwbegincode{17}\sublabel{NWmodE-typ5-2}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-typ5-2}}}\moddef{types~{\nwtagstyle{}\subpageref{NWmodE-typ5-1}}}\plusendmoddef
typedef struct constraint_t \{
    element_t element;
    int node[2];
    int vars[9];
    double relpos[3];
\} constraint_t;

\nwendcode{}\nwbegindocs{18}\nwdocspar

\nwenddocs{}\nwbegincode{19}\sublabel{NWmodE-modF-4}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-modF-4}}}\moddef{model functions~{\nwtagstyle{}\subpageref{NWmodE-modF-1}}}\plusendmoddef
static element_t* constraint_init(mesh_t mesh, const char* model,
                                  model_element_t* modelfunc)
\{
    constraint_t* self = (constraint_t*)
        mempool_cget(mesh_pool(mesh), sizeof(*self));

    self->element.data = self;
    self->element.model = modelfunc;

    if (mesh_num_param_nodes(mesh) != 2)
        mesh_error(mesh, "Incorrect number of nodes for rigid constraint");
    self->node[0] = mesh_param_node(mesh, 0);
    self->node[1] = mesh_param_node(mesh, 1);

    return &(self->element);
\}

\nwendcode{}\nwbegindocs{20}\nwdocspar

\nwenddocs{}\nwbegincode{21}\sublabel{NWmodE-modF-5}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-modF-5}}}\moddef{model functions~{\nwtagstyle{}\subpageref{NWmodE-modF-1}}}\plusendmoddef
static void constraint_set_position(void* pself, mesh_t mesh)
\{
    constraint_t* self = (constraint_t*) pself;
    double* x1 = mesh_node(mesh, self->node[0])->x;
    double* x2 = mesh_node(mesh, self->node[1])->x;

    self->relpos[0] = x2[0] - x1[0];
    self->relpos[1] = x2[1] - x1[1];
    self->relpos[2] = x2[2] - x1[2];
\}

\nwendcode{}\nwbegindocs{22}\nwdocspar

\nwenddocs{}\nwbegincode{23}\sublabel{NWmodE-modF-6}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-modF-6}}}\moddef{model functions~{\nwtagstyle{}\subpageref{NWmodE-modF-1}}}\plusendmoddef
static void constraint_vars(void* pself, vars_mgr_t vars)
\{
    constraint_t* self = (constraint_t*) pself;

    self->vars[0] = vars_node(vars, self->node[0], "x");
    self->vars[1] = vars_node(vars, self->node[0], "y");
    self->vars[2] = vars_node(vars, self->node[0], "rz");

    self->vars[3] = vars_node(vars, self->node[1], "x");
    self->vars[4] = vars_node(vars, self->node[1], "y");
    self->vars[5] = vars_node(vars, self->node[1], "rz");

    /* Multiplier variables */
    self->vars[6] = vars_branch(vars, "lx" );
    self->vars[7] = vars_branch(vars, "ly" );
    self->vars[8] = vars_branch(vars, "lrz");
\}

\nwendcode{}\nwbegindocs{24}\nwdocspar

Recall that the constraint equations are
\[
  C =
  \begin{pmatrix}
    (r + Q(\omega) (X-R)) - x \\
    \omega - \theta
  \end{pmatrix} = 0
\]
and the corresponding tangent matrix (in block form) is
\[
  \frac{\partial C}{\partial (r, \omega, x, \theta)} =
    \begin{pmatrix}
      -I & \frac{\partial Q}{\partial \omega} (X-R) & -I &  0 \\
       0 & 1                                        &  0 & -1
    \end{pmatrix}
\]

\nwenddocs{}\nwbegincode{25}\sublabel{NWmodE-**pk-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-**pk-1}}}\moddef{contribute $\partial C / \partial (x, \theta)$~{\nwtagstyle{}\subpageref{NWmodE-**pk-1}}}\endmoddef
Kij(7,4) = Kij(4,7) = -1;
Kij(8,5) = Kij(5,8) = -1;
Kij(9,6) = Kij(6,9) = -1;
\nwused{\\{NWmodE-modF-8}}\nwendcode{}\nwbegindocs{26}\nwdocspar

\nwenddocs{}\nwbegincode{27}\sublabel{NWmodE-**pu-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-**pu-1}}}\moddef{contribute $\partial C^T \lambda / \partial (x, \theta)$~{\nwtagstyle{}\subpageref{NWmodE-**pu-1}}}\endmoddef
Ri(4) = -xi(7);
Ri(5) = -xi(8);
Ri(6) = -xi(9);
\nwused{\\{NWmodE-modF-7}}\nwendcode{}\nwbegindocs{28}\nwdocspar

\nwenddocs{}\nwbegincode{29}\sublabel{NWmodE-**pk.2-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-**pk.2-1}}}\moddef{contribute $\partial C / \partial (r, \omega)$~{\nwtagstyle{}\subpageref{NWmodE-**pk.2-1}}}\endmoddef
Kij(7,1) = Kij(1,7) =  1;
Kij(8,2) = Kij(2,8) =  1;

Kij(7,3) = Kij(3,7) = \LA{}$(\partial Q(X-R) / \partial \omega)_1$~{\nwtagstyle{}\subpageref{NWmodE-**pd-1}}\RA{};
Kij(8,3) = Kij(3,8) = \LA{}$(\partial Q(X-R) / \partial \omega)_2$~{\nwtagstyle{}\subpageref{NWmodE-**pd.2-1}}\RA{};
Kij(9,3) = Kij(3,9) =  1;

\nwused{\\{NWmodE-modF-8}}\nwendcode{}\nwbegindocs{30}\nwdocspar

\nwenddocs{}\nwbegincode{31}\sublabel{NWmodE-**pu.2-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-**pu.2-1}}}\moddef{contribute $\partial C^T \lambda / \partial (r, \omega)$~{\nwtagstyle{}\subpageref{NWmodE-**pu.2-1}}}\endmoddef
Ri(1) = xi(7);
Ri(2) = xi(8);
Ri(3) = \LA{}$(\partial Q(X-R) / \partial \omega)_1$~{\nwtagstyle{}\subpageref{NWmodE-**pd-1}}\RA{} * xi(7) +
        \LA{}$(\partial Q(X-R) / \partial \omega)_1$~{\nwtagstyle{}\subpageref{NWmodE-**pd-1}}\RA{} * xi(8) +
        xi(9);
\nwused{\\{NWmodE-modF-7}}\nwendcode{}\nwbegindocs{32}\nwdocspar

\nwenddocs{}\nwbegincode{33}\sublabel{NWmodE-conK-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-conK-1}}}\moddef{contribute $C(x, y)$~{\nwtagstyle{}\subpageref{NWmodE-conK-1}}}\endmoddef
Ri(7) = xi(1) - xi(4) + (\LA{}$(Q(X-R))_1$~{\nwtagstyle{}\subpageref{NWmodE-$(QC-1}}\RA{} - relpos[0]);
Ri(8) = xi(2) - xi(5) + (\LA{}$(Q(X-R))_2$~{\nwtagstyle{}\subpageref{NWmodE-$(QC.2-1}}\RA{} - relpos[1]);
Ri(9) = xi(3) - xi(6);
\nwused{\\{NWmodE-modF-7}}\nwendcode{}\nwbegindocs{34}\nwdocspar

\nwenddocs{}\nwbegincode{35}\sublabel{NWmodE-$(QC-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-$(QC-1}}}\moddef{$(Q(X-R))_1$~{\nwtagstyle{}\subpageref{NWmodE-$(QC-1}}}\endmoddef
( c * relpos[0]  +  -s * relpos[1])
\nwused{\\{NWmodE-conK-1}}\nwendcode{}\nwbegindocs{36}\nwdocspar

\nwenddocs{}\nwbegincode{37}\sublabel{NWmodE-$(QC.2-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-$(QC.2-1}}}\moddef{$(Q(X-R))_2$~{\nwtagstyle{}\subpageref{NWmodE-$(QC.2-1}}}\endmoddef
( s * relpos[0]  +   c * relpos[1])
\nwused{\\{NWmodE-conK-1}}\nwendcode{}\nwbegindocs{38}\nwdocspar

\nwenddocs{}\nwbegincode{39}\sublabel{NWmodE-**pd-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-**pd-1}}}\moddef{$(\partial Q(X-R) / \partial \omega)_1$~{\nwtagstyle{}\subpageref{NWmodE-**pd-1}}}\endmoddef
(-s * relpos[0]  +  -c * relpos[1])
\nwused{\\{NWmodE-**pk.2-1}\\{NWmodE-**pu.2-1}}\nwendcode{}\nwbegindocs{40}\nwdocspar

\nwenddocs{}\nwbegincode{41}\sublabel{NWmodE-**pd.2-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-**pd.2-1}}}\moddef{$(\partial Q(X-R) / \partial \omega)_2$~{\nwtagstyle{}\subpageref{NWmodE-**pd.2-1}}}\endmoddef
( c * relpos[0]  +  -s * relpos[1])
\nwused{\\{NWmodE-**pk.2-1}}\nwendcode{}\nwbegindocs{42}\nwdocspar

\nwenddocs{}\nwbegincode{43}\sublabel{NWmodE-defc-1}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-defc-1}}}\moddef{define locals for residual computation~{\nwtagstyle{}\subpageref{NWmodE-defc-1}}}\endmoddef
#define xi(i) xlocal[(i)-1]
double xlocal[9];

double* relpos = self->relpos;
double  c, s;

assemble_matrix_add(x, self->vars, 9, xlocal);
c = cos(xi(6));
s = sin(xi(6));
\nwused{\\{NWmodE-modF-7}\\{NWmodE-modF-8}}\nwendcode{}\nwbegindocs{44}\nwdocspar

\nwenddocs{}\nwbegincode{45}\sublabel{NWmodE-modF-7}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-modF-7}}}\moddef{model functions~{\nwtagstyle{}\subpageref{NWmodE-modF-1}}}\plusendmoddef
static void constraint_R(void* pself, assemble_matrix_t *R,
                         assemble_matrix_t* x,
                         assemble_matrix_t* v,
                         assemble_matrix_t* a)
\{
    constraint_t* self = (constraint_t*) pself;

    #define Ri(i) Rlocal[(i)-1]
    double Rlocal[9];

    \LA{}define locals for residual computation~{\nwtagstyle{}\subpageref{NWmodE-defc-1}}\RA{}
    memset(Rlocal, 0, sizeof(Rlocal));

    \LA{}contribute $\partial C^T \lambda / \partial (x, \theta)$~{\nwtagstyle{}\subpageref{NWmodE-**pu-1}}\RA{}
    \LA{}contribute $\partial C^T \lambda / \partial (r, \omega)$~{\nwtagstyle{}\subpageref{NWmodE-**pu.2-1}}\RA{}
    \LA{}contribute $C(x, y)$~{\nwtagstyle{}\subpageref{NWmodE-conK-1}}\RA{}

    #undef xi
    #undef Ri

    assemble_matrix_add(R, self->vars, 9, Rlocal);
\}

\nwendcode{}\nwbegindocs{46}\nwdocspar

\nwenddocs{}\nwbegincode{47}\sublabel{NWmodE-modF-8}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-modF-8}}}\moddef{model functions~{\nwtagstyle{}\subpageref{NWmodE-modF-1}}}\plusendmoddef
static void constraint_dR(void* pself, assemble_matrix_t* dR,
                          double cx, assemble_matrix_t* x,
                          double cv, assemble_matrix_t* v,
                          double ca, assemble_matrix_t* a)
\{
    constraint_t* self = (constraint_t*) pself;

    #define Kij(i,j) Klocal[(i) + (j)*9 - 10]
    double Klocal[81];

    \LA{}define locals for residual computation~{\nwtagstyle{}\subpageref{NWmodE-defc-1}}\RA{}
    memset(Klocal, 0, sizeof(Klocal));

    \LA{}contribute $\partial C / \partial (x, \theta)$~{\nwtagstyle{}\subpageref{NWmodE-**pk-1}}\RA{}
    \LA{}contribute $\partial C / \partial (r, \omega)$~{\nwtagstyle{}\subpageref{NWmodE-**pk.2-1}}\RA{}

    #undef xi
    #undef Kij

    assemble_matrix_add(dR, self->vars, 9, Klocal);
\}

\nwendcode{}\nwbegindocs{48}\nwdocspar

\nwenddocs{}\nwbegincode{49}\sublabel{NWmodE-modF-9}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-modF-9}}}\moddef{model functions~{\nwtagstyle{}\subpageref{NWmodE-modF-1}}}\plusendmoddef
static void constraint_output(void* pself, netout_t* netout)
\{
    constraint_t* self = (constraint_t*) pself;

    netout_string        (netout, "model",     "constraint");
    netout_int_matrix    (netout, "node",      self->node, 1, 2);
    netout_int_matrix    (netout, "vars",      self->vars, 1, 9);
\}

\nwendcode{}\nwbegindocs{50}\nwdocspar

\nwenddocs{}\nwbegincode{51}\sublabel{NWmodE-regF-2}\nwmargintag{{\nwtagstyle{}\subpageref{NWmodE-regF-2}}}\moddef{register models~{\nwtagstyle{}\subpageref{NWmodE-regF-1}}}\plusendmoddef
memset(&model, 0, sizeof(model));
model.init         = constraint_init;
model.set_position = constraint_set_position;
model.vars         = constraint_vars;
model.R            = constraint_R;
model.dR           = constraint_dR;
model.output       = constraint_output;
model_mgr_add_element(model_mgr, "constraint", &model);

\nwendcode{}

\nwixlogsorted{c}{{$(Q(X-R))_1$}{NWmodE-$(QC-1}{\nwixu{NWmodE-conK-1}\nwixd{NWmodE-$(QC-1}}}%
\nwixlogsorted{c}{{$(Q(X-R))_2$}{NWmodE-$(QC.2-1}{\nwixu{NWmodE-conK-1}\nwixd{NWmodE-$(QC.2-1}}}%
\nwixlogsorted{c}{{contribute $C(x, y)$}{NWmodE-conK-1}{\nwixd{NWmodE-conK-1}\nwixu{NWmodE-modF-7}}}%
\nwixlogsorted{c}{{contribute $\partial C / \partial (r, \omega)$}{NWmodE-**pk.2-1}{\nwixd{NWmodE-**pk.2-1}\nwixu{NWmodE-modF-8}}}%
\nwixlogsorted{c}{{contribute $\partial C / \partial (x, \theta)$}{NWmodE-**pk-1}{\nwixd{NWmodE-**pk-1}\nwixu{NWmodE-modF-8}}}%
\nwixlogsorted{c}{{contribute $\partial C^T \lambda / \partial (r, \omega)$}{NWmodE-**pu.2-1}{\nwixd{NWmodE-**pu.2-1}\nwixu{NWmodE-modF-7}}}%
\nwixlogsorted{c}{{contribute $\partial C^T \lambda / \partial (x, \theta)$}{NWmodE-**pu-1}{\nwixd{NWmodE-**pu-1}\nwixu{NWmodE-modF-7}}}%
\nwixlogsorted{c}{{define locals for residual computation}{NWmodE-defc-1}{\nwixd{NWmodE-defc-1}\nwixu{NWmodE-modF-7}\nwixu{NWmodE-modF-8}}}%
\nwixlogsorted{c}{{model functions}{NWmodE-modF-1}{\nwixu{NWmodE-modD.2-1}\nwixd{NWmodE-modF-1}\nwixd{NWmodE-modF-2}\nwixd{NWmodE-modF-3}\nwixd{NWmodE-modF-4}\nwixd{NWmodE-modF-5}\nwixd{NWmodE-modF-6}\nwixd{NWmodE-modF-7}\nwixd{NWmodE-modF-8}\nwixd{NWmodE-modF-9}}}%
\nwixlogsorted{c}{{model-rigid.c}{NWmodE-modD.2-1}{\nwixd{NWmodE-modD.2-1}}}%
\nwixlogsorted{c}{{model-rigid.h}{NWmodE-modD-1}{\nwixd{NWmodE-modD-1}}}%
\nwixlogsorted{c}{{$(\partial Q(X-R) / \partial \omega)_1$}{NWmodE-**pd-1}{\nwixu{NWmodE-**pk.2-1}\nwixu{NWmodE-**pu.2-1}\nwixd{NWmodE-**pd-1}}}%
\nwixlogsorted{c}{{$(\partial Q(X-R) / \partial \omega)_2$}{NWmodE-**pd.2-1}{\nwixu{NWmodE-**pk.2-1}\nwixd{NWmodE-**pd.2-1}}}%
\nwixlogsorted{c}{{register models}{NWmodE-regF-1}{\nwixu{NWmodE-regL-1}\nwixd{NWmodE-regF-1}\nwixd{NWmodE-regF-2}}}%
\nwixlogsorted{c}{{registration function}{NWmodE-regL-1}{\nwixu{NWmodE-modD.2-1}\nwixd{NWmodE-regL-1}}}%
\nwixlogsorted{c}{{types}{NWmodE-typ5-1}{\nwixu{NWmodE-modD.2-1}\nwixd{NWmodE-typ5-1}\nwixd{NWmodE-typ5-2}}}%
\nwbegindocs{52}\nwdocspar
\nwenddocs{}


\documentclass[../PHYS306Notes.tex]{subfiles}

\begin{document}
\section{Lecture 10}
\subsection{Lecture Notes - Intro to Coupled Oscillators}
\subsubsection{Analysis with Newtonian Mechanics}
\begin{center}
    \includegraphics[scale=0.5]{Lecture-10/w10-img1.png}
\end{center}
A system of two coupled harmonic oscillators has spring constants $k$ (left spring), $k_{12}$ (middle spring) and $k$ (right spring). The displacements of the blocks are measured from equilibrium. The forces on the blocks are therefore given by:
\[F_1 = -kx_1 - k_{12}(x_1 - x_2)\]
\[F_2 = -kx_2 - k_{12}(x_2 - x_1)\]
The Lagrangian formulation gives the same result; see worksheet!
\end{document}


\subsection{Double integral of scalar fields}