One US Liquid Gallon is 231 Cubic Inches.
1.5g = 346.5ci
2g = 462ci
3root(246.5)=6.27006882. A tank with edges of these dimensions will hold precisely 1.5 gallons. However, you will want some room from top of the tank to water level so adjust accordingly.
3root(462)=7.73061405. A tank with edges of these dimensions will hold precisely 2 gallons. However, you will want some room from top of the tank to water level so adjust accordingly.
It has been a while since I have been in a math class so please correct me if I am wrong here.