## 4 Modeling and Simulation of Overall Operational Conditions  
The first two services of the _mechatronics-twin_ framework (i.e., the service \(\blacklozenge\) and \(\blacklozenge\) shown in Figure 1) provide the support for virtual replication of socket operation. The goal is to elicit the most fundamental operational characteristics of a prosthetic device as an integral part of an amputee. In particular, it gives an estimation of the piston-forces and moments within the amputee stump-socket assembly during walking. Knowledge of such physical interactions is essential for a more detailed analysis of stump and prosthesis dynamics. The work is based on _OpenSim_[60], which is an open source tool for the modeling, simulating, and analyzing of neuromunculoskeletal systems, and _ANSYS Workbench_[61], which is a commercial software tool for advanced FEA of intra-socket load distribution. The work starts with a quantification of amputee body geometries, sizes of the pelvis-femur structure, and prosthetic socket based on a combination of measurement and estimation. As described previously, stump measurement by scanning constitutes the basis for identifying the properties of the femur. These geometry data are not only essential for visual representation of the bodies, but also important in the estimation of piston-forces with _inverse dynamics_ when combined with a configuration of associated body masses. To achieve good scaling in biomechanical models, proper measurements of the limbs are required to determine the joints connecting the various bodies. The masses of the residual limb are initially approximated by equating the volumetric density of the default healthy limb to the residual limb. The _Static Optimisation Tool_ of _OpenSim_ is then used for a further adjustment of these masses regarding the kinematics and ground reaction forces of the test subject. In [62], a similar approach is used to develop a transfemoral biomechanical model in _OpenSim_ to estimate joint torques. A biomechanical model for identifying the piston-forces of transfemoral or transtibial prosthesis within dynamic gait cycles is then constructed with _OpenSim_ as shown in Figure 2. In particular, an amputee leg model, shown in Figure 3, is developed to stipulate the related multi-body parameters of particular concern. These include: (1) _Interface_r_, representing the imaginary rigid joint between the femur and the socket located at the _COM_ (Center of Mass) of the stump and (2) _Interface_SP_, representing the joint between the socket (S) and femur pylon (\(P\)). During a gait cycle, the piston-forces and moments are related to the contact forces between stump and socket as shown in Figure 3. The conjunction of all force vectors \(F_{C}\) over the discrete regions of stump surface \(t\) at each specific gait phase is equivalent to the piston force \(F_{P}\) and moments of the same stump. The contact force \(F_{C}\) at each region is a composition of normal force experienced from the pressure \(F_{N}\) and shear force \(F_{S}\) of the same region. Given such force and moment data, the piston-forces and moments are calculated according to the simulated ground reaction forces during gait cycles and the corresponding multi-body transformation through the _Inverse Dynamics Tool_ of _OpenSim_. In Figure 4, one example of the piston forces and moments over 7 gait cycles is shown. They are represented in terms of percentage of gait cycle. The sampling frequency for the simulation is 100 Hz. These internal joint reaction data are then exported for the analysis of socket-stump interface conditions by FEA (i.e., the service ), to provide an effective characterization of possible intra-socket load conditions of concern before any further physical tests. Within the _mechatronics-twin_ framework, the FEA by _ANSYS Workbench_ provides the support for establishing the virtual behaviors relating to the contact forces on stump surface, based on the internal joint reaction data from the biomechanical modeling and simulation.