# A General Framework for Crankshaft Balancing and Counterweight Design
## 3 Tool Design
### Secondary Reciprocating Forces Balancing  
The balancing of the secondary reciprocating forces needs the following additional inputs:  
* The total length of the secondary balancing shafts (which corresponds to the distance between the outer counterweights of the shafts), \(l_{sl,2}\);
* The radius of the centre of gravity of the secondary counterweights, \(r_{c,2}\). Such inputs can be visualised in Figure 7. Unlike the centrifugal and primary reciprocating forces, where the geometry matrix of the counterweights can be directly derived from the crankshaft matrix, the geometry matrices for the counterweights of the secondary reciprocating forces are more complex to derive, since they rotate at double the speed of the crankshaft and the relative position to the other components can change drastically between different crankshaft configurations. The method exploits the fact that the reciprocating forces are always aligned with the cylinder axis and, therefore, the counterweights are parallel to the cylinder axis when the resultant force/moment of the cranks is maximum: in fact, only when the counterweights are parallel to the \(z\)-axis they generate the maximum vertical force and maximum moment around the \(x\)-axis. So, the code will proceed to compute the maximum values of resultant force and moments generated by the crankshaft, through the following equations:  
\[ \begin{cases}F_{a,2,res}=\sum_{i=1}^{N_{c}}m_{alt}\Lambda\omega^{2}r\cos(2 \arccos(CS(3,i)))\\ M_{a,2,res}=\sum_{i=1}^{N_{c}}m_{alt}\Lambda\omega^{2}r\cos(2\arccos(CS(3,i))) CS(2,i)\end{cases}  \tag{18}\]  
When the maximum value of the force and moment is obtained, the corresponding crank angle of the first crank is saved and defined as \(\epsilon\). With this premise, it is then possible to create the geometry matrices for the counterweights of both shafts:  
\[CW_{2,r}(1,k)=\sin(2\theta-2\epsilon+\pi(k-1))\qquad CW_{2,cr}(1,k)=-CW_{2,r} (1,k) \tag{19}\]  
\[CW_{2,r}(2,k)=\frac{-l_{sh,2}}{2}+l_{sh,2}(k-1)\qquad CW_{2,cr}(2,k)=\frac{-l _{sh,2}}{2}+l_{sh,2}(k-1) \tag{20}\]  
\[CW_{2,r}(3,k)=\sin(2\theta-2\epsilon+\pi(j-1))\qquad CW_{2,cr}(3,k)=CW_{2,r} (3,k) \tag{21}\]  
where \(k=1\wedge k=2\), and \(j=k\). Similarly to the primary reciprocating forces, the matrices found with these equations are those relative to the case where the moment resultant is different from zero. When the other case is encountered the matrix becomes a vertical array per shaft with the same \(x\) and \(z\) components for \(k=1\), with \(j=2\), and the \(y\)-component equal to zero. The single mass on each shaft can be also divided into multiple masses, if the symmetry around the mid-point of the shafts is maintained. Once the matrices have been found, the equations of equilibrium are used to find the masses to apply to the counterweights, \(m_{c,2}\). Effectively, the method follows the same exact pattern as for the primary reciprocating forces:\[ \begin{cases}\sum_{i=1}^{N_{cr}}m_{alt}\Lambda\omega^{2}r\cos(2\arccos(3,i))= \sum_{j=1}^{N_{cr}2}m_{c,2}4\omega^{2}r_{c,2}CW_{2,r}(3,j)+\\ +\sum_{j=1}^{N_{cr}2}m_{c,2}4\omega^{2}r_{c,1}CW_{2,\sigma}(3,j)\\ \\ \sum_{i=1}^{N_{cr}}m_{alt}\Lambda\omega^{2}r\cos(2\arccos(3,i))CS(2,i)=\sum_{j =1}^{N_{cr}2}m_{c,2}\omega^{2}r_{c,2}CW_{2,r}(3,j)CW_{2,r}(2,j)+\\ +\sum_{j=1}^{N_{cr}2}m_{c,2}\omega^{2}r_{c,2}CW_{2,r}(3,j)CW_{2,\sigma}(2,j) \end{cases}  \tag{22}\]  
From these equations, we can then derive:  
\[ \begin{cases}m_{c,2}=\frac{\sum_{j=1}^{N_{cr}}m_{alt}\Lambda r\cos(2\arccos(3, j))}{\sum_{j=1}^{N_{cr}2}4r_{c,2}CW_{2,r}(3,j)+\sum_{j=1}^{N_{cr}2}4r_{c,2}CW_{2,r}(3,j)}\\ m_{c,2}=\frac{\sum_{j=1}^{N_{cr}}m_{alt}\Lambda r\cos(2\arccos(3,i))CS(2,i)}{ \sum_{j=1}^{N_{cr}2}4r_{c,2}CW_{2,r}(3,j)CW_{2,r}(2,j)+\sum_{j=1}^{N_{cr}2}4r_ {c,2}CW_{2,r}(3,j)CW_{2,\sigma}(2,j)}\end{cases}  \tag{23}\]  
Just like the primary reciprocating forces, only one equation from the set in Equation (23) is necessary to find the mass of the counterweights.