0

I am trying to plot this complex def function from a research paper that I read for a project and I keep getting that the map function is not iterable. When I run the code by itself, it's fine, but when I try to do other functions utilizing the given code, it gives an error.

The full code will be below:

# include all functions from the math and numpy library
import math as m
import numpy as np
import matplotlib.pyplot as plt

# definition of the function Sc see Table 2 for details
def Sc(Dd, ki=0.23, ei=5.6*(10**-2), Ci=88, T=298.15, sigma=0.072, gmax=10, g=1+1e-11, inc=1.01):
    # calculate the A parameter in equation 9
    A = 8.69251e-6*sigma/T
    # returns H(xi) as defined in equation 10
    xi = map(lambda x: x if x < 1 else 1, Ci*(g**3.0 - 1.0)/ei)
    # calculates the dot product of the hygroscopicity and solub. vectors in Eq. 10
    k = np.dot(ki,(ei*xi))
    # defines the function given by equation 9
    S = lambda D, Dd, k, A: (D**3.0-Dd**3.0)/(D**3.0-Dd**3.0*(1.0-k))*m.exp(A/D)
    # implementation of a pairwise max function; f(2,3) returns 3
    f = lambda x,y: x if x > y else y
    # returns 1 when g > gmax otherwise return the larger value S(g*Dd) or S(g*Dd*inc)
    return 1 if g > gmax else np.reduce(f,[S(g*Dd,Dd,k,A), \
    Sc(Dd,ki,ei,Ci,T=T,sigma=sigma,gmax=gmax,inc=inc,g=g*inc)])




Dd1=0.01*(10**-6)
print(Sc(Dd1))

I was trying to plot the given code from the research paper, but it did not work and it keeps giving me the following error: xi = map(lambda x: x if x < 1 else 1, Ci*(g**3.0 - 1.0)/ei)

TypeError: 'float' object is not iterable

This error occurs whether I try to plot or when I simply want to print out an output value

1

0