Electromagnetic and beam dynamics studies for high gradient accelerators at terahertz frequencies