It's just another force, so you would treat it pretty much the same as you would treat gravity, a propeller, or any other force. There are a few points I'll make to help clarify for you:
- The string binds the two systems together, meaning that each is now an input to the other (hopefully I'll clarify this with points below).
- A string in tension is effectively rigid. A string in compression doesn't transmit force. So you'll need case statements such that the force is only applied across the systems when the string is in tension and that there is no effect when the string is in compression.
- The location of the force is wherever the string is tied to the box (call that position_box or p_box for short). Similarly, for the balloon, the location of the force is wherever the string is tied to the balloon (p_bln).
- The force is a vector that acts along [p_bln-p_box].
- Relating to point (2) above, the force is only transmitted when norm([p_bln-p_box]) >= L_string. Technically the norm shouldn't ever exceed the length of the string, but resolving that length back to L_string could be the force that is applied to each body.
So, this would differ a little from gravity where gravity is always a vector pointing down and always acts on the center of mass, the string is a vector force of variable direction, that always acts at the point of attachment, that may not exist (if the box is closer to the balloon than the length of the string).
Gravity acts through the center of mass, so, provided there are no other reaction forces (not hinged/pivoting, negligible air resistance), there's no torque applied to the body. What you'll find is that, by acting on a point not the center of mass, the string will apply a torque to both bodies, in addition to pulling them.
As I mentioned, the actual distance between the two points may exceed the length of the string; this has to deal with joint stability and how you choose to solve and resolve forces across joints.
FYI, I'm not sure what your background is, but you're entering a pretty complex field by allowing force transmission across a flexible joint. I'm a fan of Rigid Body Dynamics Algorithms by Roy Featherstone, but there are certainly a number of other algorithms that you can use to solve this dynamic system. It looks to me like Featherstone's algorithm is at the heart of Matlab's SimMechanics toolbox, but that's just an educated guess; it could of course be something else.
If you were going to model this in SimMechanics, you would look for two spherical joints, one on each body, with a telescoping joint that allows for motion from 0 to L_string. At lengths < 0, the objects collide, at lengths > L_string the string is taut. Please comment if you would like more guidance, but I think this is about what you were looking for.
I found this group of examples on the Matlab FileExchange to be very useful when developing models in SimMechanics. The most useful thing I found there was a model (screenshots below) that shows how to interface a SimMechanics block to a SimScape block. This allows a SimMechanics "Prismatic Joint" to be used with a SimScape "Translational Hard Stop" block. Using this setup, you can set the limits on the prismatic joint to start at L_String, the limits on the translational hard stop to be 0 to L_String, and then you can adjust the end stop spring constants and damping until you get a reasonable reaction.
The spring/damping constants will adjust the "snap" applied to each body when the string pulls taut (or when the two collide). You can adjust the upper/lower end stop constants such that a collision (L = 0) is different than the string pulling tight (L = L_String). Again, this should be a prismatic joint inserted between your two spherical joints.
Here's the screenshots! First, create a translational interface between SimScape and SimMechanics: (Provided in the FileExchange package I linked above).
Then, add that interface to a prismatic joint:
Configure the prismatic joint to start at L=L_String. Ensure that there's no internal mechanics set and that motion is automatically computed with force provided by input (this is required to work with the translational interface).
Then, configure the translational hard stop such that the limits are from 0 to L_String. At this point I would accept the default stiffness and damping and run the simulation to see how you think it works. My defaults are because I work with some colossal industrial equipment that uses tensioners bigger than I am. I think the stock defaults are somewhere ~100.
Finally, I would suggest you save that configuration as a custom library block so you can have it in the future. You can do more complex things, like mask the L_String parameters such that you can customize the default lengths, etc. from the custom library block, but a how-to for that is beyond the scope of what I'm covering here. Anyways, once you've set everything up, I would suggest you just link a block to your string and run a quick simulation. Edit the parameters as you see fit until you get the desired response or it matches your experimental data.