The number of families of subsets of $\{1,2,...,n\}$ whose union is not the whole set.
A051185 is the number of (pairwise-) intersecting families. Two subsets of $\{1,\ldots, n\}$ intersect iff the union of their complements is not $\{1,\ldots,n\}$. But you want not just the pairwise unions but the union of
all sets in your family to not be the whole set. So you should get a different result for $n=3$: the family $\{\{1,2\}, \{1,3\}, \{2,3\}\}$ is pairwise intersecting, so it should be included in A051185, but its complements $\{\{3\},\{2\},\{1\}\}$ should not be included in your count.
In fact, I get $38$, not $40$, for $n=3$ and $942$, not $1376$, for $n=4$.
If I understand correctly what you're trying to count, your code is wrong. I think the sequence you're after is this one: https://oeis.org/A005530