  We describe a simple method to derive high performance semidefinite
programming relaxations for optimizations over complex and real operator
algebras in finite dimensional Hilbert spaces. The method is very flexible,
easy to program and allows the user to assess the behavior of finite
dimensional quantum systems in a number of interesting setups. We use this
method to bound the strength of quantum nonlocality in bipartite and tripartite
Bell scenarios where the dimension of a subset of the parties is bounded from
above. We derive new results in quantum communication complexity and prove the
soundness of the prepare-and-measure dimension witnesses introduced in [Phys.
Rev. Lett. 105, 230501 (2010)]. Finally, we propose a new dimension witness
that can distinguish between classical, real and complex two-level systems.
