Bacterial chemotaxis shape optimization of electromagnetic devices