I had atrial fibrillation for almost 2 years…and cured it! In other words I got off the high dose of beta blockers I was on and my heart remained stable. I made sure to exercise daily and I NEVER EVER drank coffee or tea or alcohol again. Chocolate and certain stimulant meds I also avoided and still steer clear of. Even too many carbs will get my heart racing. Of course, I have given in over the years to temptation and my heart will let me know that I am tempting fate.
Possibly like you, I suffer from IBS and have since my early teens. Thankfully, I know what to avoid (dairy, sugar, rice…). I take 300 ml of magnesium citrate before bed (it helps with sleep) to keep gently regular the next morning without fail which for me is essential or I can suffer from cramps as painful as childbirth. I doubt you are taking 1500 mg of magnesium citrate or you would have major diarrhea. It sure sounds excessive in any case… Quote: 'The current RDA for adults is between 320 and 420mg daily, and the average US intake is around 250mg daily.'
Apparently, after vitamin D, we are most lacking in magnesium which has been depleted from the soil our vegetables grow in resulting in deficiencies. An interesting article to read about magnesium is in Psychology Today called Magnesium, the Original Chill Pill. https://www.psychologytoday.com/ca/blog/evolutionary-psychiatry/201106/magnesium-and-the-brain-the-original-chill-pill
All the best to you! Keep as far away as you can from caffeine in coffee, tea, Coke, chocolate etc…