I am looking to use python (in place of excel) for an assignment in a non-programming related engineering class. I am trying to find the optimum number of tubes in a heat exchanger for several differently sized tubes. This number depends on half a dozen related quantities and has a few constraints. Few of these equations are linear, but the number of tubes has to be a positive integer. I know about the scipy.optimize package and using math.ceil to turn the trial numbers into integers, but there has to be a nicer package out their somewhere.

I put the code as it stands [here](https://github.com/wdkrnls/Design-Homework-2/blob/master/hw2.py).

Below is the section with the optimization problem. The trouble is that fsolve doesn't change enough to change the initial guess with the m.ceil in there.

```
def ntf():
    fdn = 0.85 * 62.43 
    #            lb/ft^3
    vsb = fdn * 5 * (1.076 * 10 ** -5)
    #     lb/ft^3 * Cst * (ft^2/s) / Cst
    kf  = 0.08
    fcp  = 0.5
    #     Btu/ft^2-hr-(F/ft)
    dua = uaf()

    for i, x in enumerate(bwg16):
        def func(nt):
            nt   = m.ceil(nt)
            vel  = velf(nt, x)
            nre  = nref(vel, bwg16[x][1], fdn, vsb)
            npr  = nprf(fcp, vsb, kf)
            nnu  = nnuf(nre, npr, vsb, vsb)
            idc  = idcf(nnu, bwg16[x][1], kf)
            ohtc = ohtcf(idc, x)
            fa   = nt * bwg16[x][3]
            sa   = 40 * nt * bwg16[x][2] 
            ua   = ohtc * sa
            diff = ua - dua
            return diff

        nts[x] = opt.fsolve(func, 40, xtol = 0.01)
        # TODO:  Optimize nt such that diff is positive but as close to zero as
        # possible.  nt needs to be an integer.  Then, I need to be able to
        # extract nt, nre, vel, and sa into a dictionary to compare later.  If
        # all else fails, I suppose I could recalculate the rest later given
        # the working nt.

    return nts

```

In summary, can you recommend a better package or function in python that could handle this problem?

*Edit: I got rid of an type error problem I was having due to forgetting some return statements.*