Your raw damage is calculated by multiplying the P value of your pick x Idle Power Multiplier x Active Power Multiplier x the multiplier of the appropriate power upgrade for the kind of click (manual or auto). (Your effective damage is your raw damage minus the current ore's defense.)
Idle Power Multiplier is calculated (how?) from Idle Power. Idle Power increases over time, about 1 every five seconds (it is slightly randomized but does not deviate significantly from the average). This happens all the time, even if the game is closed (though not if the game is open-but-paused, e.g. in a hidden tab or a minimized window).
Active Power Multiplier is calculated (how?) from Active Power. Active Power increases while the game is open. It also increases as a result of clicking on the ore. Not every click causes an increase in Active Power, but it's pretty consistent, there's not a huge amount of randomness. Upgrading your auto click per second rate causes the active power to increase more quickly, though there is a limit (what?).