Bethesda-based writer Katherine Heiny spends a lot of time thinking about infidelity. Her collection of short stories, “Single, Carefree, Mellow,” stars at least a half-dozen cheaters, and her debut novel, 2017’s “Standard Deviation,” continues the trend. Though the story is more about family and friendships than adultery, the main character does consider cheating on his second wife with his first.

Heiny, in contrast, is happily married — to a former MI6 spy. 

“He helps me with whatever I’m plotting,” she says of her husband, Ian McCredie, who was under a KGB death threat when the two started dating. “He’s really good at thinking about secrets and motives.”

Heiny, who will discuss “Standard Deviation” at Solid State Books on Tuesday to mark its paperback release, also uses McCredie as a sort of template for the nerdy men who often show up in her stories.

“He’s a mathematician by trade and he tells me a lot of facts that I’m not always all that interested in,” Heiny says. “My children, they call it ‘being provoked.’ If I say something math- or science- or language-related to my husband, they say, ‘Don’t provoke him! Don’t do it!’ ”

In “Single, Carefree, Mellow,” Heiny’s main characters are all women and many are writers, but for her first novel, Heiny tried writing from a very alien perspective: Her main character, Graham, is a man who works in finance.

“It worried me that he was an investment banker,” she says. “I’m really bad at math.”

A novel both hilarious and touching, “Standard Deviation” began life as “the least satisfying short story ever written,” Heiny says.

In the original draft, Graham and his wife, Audra, are waiting to find out what’s wrong with their temperamental son — a diagnosis that never arrives. That was because, at the time she was writing the draft, Heiny didn’t know what was up with the couple’s son either.

“It’s a slow reveal in the book because it was a slow reveal to me,” she says of the son’s Asperger’s diagnosis in the finished novel. “I figured it out as I was writing it.”

Writing “Standard Deviation” also revealed a side of Heiny’s own personality. As she channeled bubbly Audra, the naturally introverted author found herself becoming more like her character, asking strangers personal questions and saying whatever was on her mind.

“She was really fun to write about,” Heiny says. “I miss her so much. I still sometimes think of things she would say.”

Solid State Books, 600 H St. NE; Tue., 7 p.m., free.

H Street’s new bookstore

Katherine Heiny’s talk will be among the last events held in Solid State Books’ small pop-up shop in The Apollo building. That’s because the independent bookstore will soon move into its permanent home, a 4,300-square-foot space on the bottom floor of the apartment/retail development. “We’re hoping to be moved in by the end of the month,” says Laura Tischler, the store’s programming coordinator. The new digs will allow Solid State to run more innovative programs, such as writers’ workshops, tastings with cookbook authors and perhaps even film viewings. The business also has the option of using The Apollo’s common areas, which include a roof deck and conservatory, Tischler says. “We are going to do all sorts of exciting things there,” she says.